core

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Header(ctx context.Context) (map[string]string, bool)

func NewContext

func NewContext(ctx context.Context, header map[string]string) context.Context

func RegisterEncoder

func RegisterEncoder(enc Encoder)

func SetDefaultEncoder

func SetDefaultEncoder(enc uint8)

Types

type CircuitBreaker

type CircuitBreaker interface {
	NewCircuitBreaker(name string) CircuitBreaker
	Run(fun func() error) error
	Available() bool
}

type CliOption

type CliOption interface {
	// contains filtered or unexported methods
}

func WithCliEncoder

func WithCliEncoder(enc Encoder) CliOption

func WithCliEndPoint

func WithCliEndPoint(ep *EndPoint) CliOption

func WithTimeout

func WithTimeout(timeout time.Duration) CliOption

type CliOptionFunc

type CliOptionFunc func(cli *Client)

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(name string, opts ...CliOption) *Client

func (*Client) GetEncoder

func (cli *Client) GetEncoder() Encoder

func (*Client) Invoke

func (cli *Client) Invoke(ctx context.Context, data []byte, funcName string, addr string) ([]byte, error)

type ClientConn

type ClientConn struct {
	// contains filtered or unexported fields
}

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func NewConn

func NewConn(srv *Service, conn net.Conn) *Conn

type Encoder

type Encoder interface {
	Encode(v interface{}) ([]byte, error)
	Decode(data []byte, v interface{}) error
	String() string
	Value() uint8
}

func GetEncoder

func GetEncoder(ty ...uint8) Encoder

type EndPoint

type EndPoint struct {
	ServiceName string
	Host        string
	Port        string
	Proto       string
	Weight      int32
	IsAlive     bool
}

func (*EndPoint) Network

func (ep *EndPoint) Network() string

func (*EndPoint) String

func (ep *EndPoint) String() string

type Handler

type Handler interface {
	Handler(ctx context.Context, _impl interface{}, enc Encoder, msg *Message, opt ...map[string]string)
}

type Message

type Message struct {
	ReqId      uint32
	Obj        string
	Func       string
	ReqData    []byte
	ReqHeader  map[string]string
	RespData   []byte
	RespHeader map[string]string
	Code       int32
	Desc       string
}

func NewMessage

func NewMessage(enc Encoder, pkg []byte) (*Message, error)

func (*Message) RequestHeaderGet

func (m *Message) RequestHeaderGet(k string) string

func (*Message) RespMessage

func (m *Message) RespMessage() *pb.RespMessage

func (*Message) RespTimeout

func (m *Message) RespTimeout() *pb.RespMessage

func (*Message) ResponseHeaderSet

func (m *Message) ResponseHeaderSet(k, v string)

type Register

type Register interface {
	Register() error
	Deregister() error
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewServe

func NewServe(name string, impl interface{}, options ...SrvOption) *Service

func (*Service) Name

func (srv *Service) Name() string

func (*Service) Serve

func (srv *Service) Serve() error

func (*Service) ServeHTTP

func (srv *Service) ServeHTTP(rw http.ResponseWriter, r *http.Request)

func (*Service) SetWaitGroup

func (srv *Service) SetWaitGroup(wg *sync.WaitGroup)

type SrvOption

type SrvOption interface {
	// contains filtered or unexported methods
}

func WithHandler

func WithHandler(handler Handler) SrvOption

func WithInvokeTimeout

func WithInvokeTimeout(timeout time.Duration) SrvOption

func WithServiceEndpoint

func WithServiceEndpoint(ep *EndPoint) SrvOption

type SrvOptionFun

type SrvOptionFun func(srv *Service)

type WKHeader

type WKHeader struct{}

type WkError

type WkError struct {
	Service string
	Code    int32
	Desc    string
}

func NewError

func NewError(name string, code int32, desc string) *WkError

func ParserError

func ParserError(msg string) *WkError

func (*WkError) Error

func (err *WkError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL