link

package
v0.1.42 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthLink        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowLink          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupLink = fmt.Errorf("proto: unexpected end of group")
)
View Source
var ErrClientAlreadyClosed = errors.New("client has closed")

ErrClientAlreadyClosed the client is closed

View Source
var ErrClientMessageTypeInvalid = errors.New("message type is invalid")

ErrClientMessageTypeInvalid the message type is invalid

View Source
var Type_name = map[int32]string{
	0: "Msg",
	1: "MsgRtn",
	2: "Ack",
}
View Source
var Type_value = map[string]int32{
	"Msg":    0,
	"MsgRtn": 1,
	"Ack":    2,
}

Functions

func RegisterLinkServer

func RegisterLinkServer(s *grpc.Server, srv LinkServer)

Types

type Client

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

Client client of contact server

func NewClient

func NewClient(ops ClientOptions) (*Client, error)

NewClient creates a new client of functions server

func (*Client) Call

func (c *Client) Call(msg *Message) (*Message, error)

Call calls a request synchronously

func (*Client) CallContext

func (c *Client) CallContext(ctx context.Context, msg *Message) (*Message, error)

CallContext calls a request with context synchronously

func (*Client) Close

func (c *Client) Close() error

Close closes client

func (*Client) Send

func (c *Client) Send(msg *Message) error

Send sends a message asynchronously

func (*Client) SendContext

func (c *Client) SendContext(ctx context.Context, msg *Message) error

SendContext sends a message with context asynchronously

type ClientConfig

type ClientConfig struct {
	Address              string        `yaml:"address" json:"address"`
	Timeout              time.Duration `yaml:"timeout" json:"timeout" default:"30s"`
	MaxReconnectInterval time.Duration `yaml:"maxReconnectInterval" json:"maxReconnectInterval" default:"3m"`
	MaxMessageSize       utils.Size    `yaml:"maxMessageSize" json:"maxMessageSize" default:"4m"`
	MaxCacheMessages     int           `yaml:"maxCacheMessages" json:"maxCacheMessages" default:"10"`
	DisableAutoAck       bool          `yaml:"disableAutoAck" json:"disableAutoAck"`
	utils.Certificate    `yaml:",inline" json:",inline"`
}

ClientConfig client config

func (ClientConfig) ToClientOptions added in v0.1.13

func (cc ClientConfig) ToClientOptions(obs Observer) (*ClientOptions, error)

ToClientOptions converts client config to client options

type ClientOptions added in v0.1.9

type ClientOptions struct {
	Address              string
	TLSConfig            *tls.Config
	MaxMessageSize       utils.Size
	MaxCacheMessages     int
	MaxReconnectInterval time.Duration
	DisableAutoAck       bool
	Observer             Observer
}

ClientOptions client options

func NewClientOptions added in v0.1.9

func NewClientOptions() ClientOptions

NewClientOptions creates client options with default values

type Context

type Context struct {
	ID    uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
	TS    uint64 `protobuf:"varint,2,opt,name=TS,proto3" json:"TS,omitempty"`
	QOS   uint32 `protobuf:"varint,3,opt,name=QOS,proto3" json:"QOS,omitempty"`
	Type  Type   `protobuf:"varint,4,opt,name=Type,proto3,enum=link.Type" json:"Type,omitempty"`
	Topic string `protobuf:"bytes,5,opt,name=Topic,proto3" json:"Topic,omitempty"`
}

func NewPopulatedContext

func NewPopulatedContext(r randyLink, easy bool) *Context

func (*Context) Descriptor

func (*Context) Descriptor() ([]byte, []int)

func (*Context) Equal

func (this *Context) Equal(that interface{}) bool

func (*Context) GoString

func (this *Context) GoString() string

func (*Context) Marshal

func (m *Context) Marshal() (dAtA []byte, err error)

func (*Context) MarshalTo

func (m *Context) MarshalTo(dAtA []byte) (int, error)

func (*Context) MarshalToSizedBuffer

func (m *Context) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Context) ProtoMessage

func (*Context) ProtoMessage()

func (*Context) Reset

func (m *Context) Reset()

func (*Context) Size

func (m *Context) Size() (n int)

func (*Context) String

func (m *Context) String() string

func (*Context) Unmarshal

func (m *Context) Unmarshal(dAtA []byte) error

func (*Context) XXX_DiscardUnknown

func (m *Context) XXX_DiscardUnknown()

func (*Context) XXX_Marshal

func (m *Context) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Context) XXX_Merge

func (m *Context) XXX_Merge(src proto.Message)

func (*Context) XXX_Size

func (m *Context) XXX_Size() int

func (*Context) XXX_Unmarshal

func (m *Context) XXX_Unmarshal(b []byte) error

type LinkClient

type LinkClient interface {
	Talk(ctx context.Context, opts ...grpc.CallOption) (Link_TalkClient, error)
	Call(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Message, error)
}

LinkClient is the client API for Link service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewLinkClient

func NewLinkClient(cc *grpc.ClientConn) LinkClient

type LinkServer

type LinkServer interface {
	Talk(Link_TalkServer) error
	Call(context.Context, *Message) (*Message, error)
}

LinkServer is the server API for Link service.

type Link_TalkClient interface {
	Send(*Message) error
	Recv() (*Message, error)
	grpc.ClientStream
}
type Link_TalkServer interface {
	Send(*Message) error
	Recv() (*Message, error)
	grpc.ServerStream
}

type Message

type Message struct {
	Context Context `protobuf:"bytes,1,opt,name=Context,proto3" json:"Context"`
	Content []byte  `protobuf:"bytes,2,opt,name=Content,proto3" json:"Content,omitempty"`
}

func NewPopulatedMessage

func NewPopulatedMessage(r randyLink, easy bool) *Message

func (*Message) Descriptor

func (*Message) Descriptor() ([]byte, []int)

func (*Message) Equal

func (this *Message) Equal(that interface{}) bool

func (*Message) GoString

func (this *Message) GoString() string

func (*Message) Marshal

func (m *Message) Marshal() (dAtA []byte, err error)

func (*Message) MarshalTo

func (m *Message) MarshalTo(dAtA []byte) (int, error)

func (*Message) MarshalToSizedBuffer

func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) Reset

func (m *Message) Reset()

func (*Message) Retain

func (m *Message) Retain() bool

Retain checks whether the message is need to retain

func (*Message) Size

func (m *Message) Size() (n int)

func (*Message) String

func (m *Message) String() string

func (*Message) Unmarshal

func (m *Message) Unmarshal(dAtA []byte) error

func (*Message) XXX_DiscardUnknown

func (m *Message) XXX_DiscardUnknown()

func (*Message) XXX_Marshal

func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Message) XXX_Merge

func (m *Message) XXX_Merge(src proto.Message)

func (*Message) XXX_Size

func (m *Message) XXX_Size() int

func (*Message) XXX_Unmarshal

func (m *Message) XXX_Unmarshal(b []byte) error

type Observer

type Observer interface {
	OnMsg(*Message) error
	OnAck(*Message) error
	OnErr(error)
}

Observer message observer interface

type Server added in v0.1.9

type Server = grpc.Server

Server is a gRPC server to serve RPC requests.

func Launch added in v0.1.9

func Launch(ops ServerOptions) (*Server, error)

Launch launches a link server

type ServerOptions added in v0.1.9

type ServerOptions struct {
	Address              string
	TLSConfig            *tls.Config
	LinkServer           LinkServer
	MaxMessageSize       utils.Size
	MaxConcurrentStreams uint32
}

ServerOptions server option

func NewServerOptions added in v0.1.9

func NewServerOptions() ServerOptions

NewServerOptions creates client options with default values

type Type added in v0.0.7

type Type int32
const (
	Msg    Type = 0
	MsgRtn Type = 1
	Ack    Type = 2
)

func (Type) EnumDescriptor added in v0.0.7

func (Type) EnumDescriptor() ([]byte, []int)

func (Type) String added in v0.0.7

func (x Type) String() string

type UnimplementedLinkServer

type UnimplementedLinkServer struct {
}

UnimplementedLinkServer can be embedded to have forward compatible implementations.

func (*UnimplementedLinkServer) Call

func (*UnimplementedLinkServer) Talk

Jump to

Keyboard shortcuts

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