Documentation ¶
Overview ¶
Package transport is a generated protocol buffer package.
It is generated from these files:
transport.proto
It has these top-level messages:
Message
Index ¶
- Variables
- type Handler
- type Message
- func (m *Message) Decode(pb proto.Message) error
- func (*Message) Descriptor() ([]byte, []int)
- func (m *Message) GetCause() string
- func (m *Message) GetError() string
- func (m *Message) GetId() string
- func (m *Message) GetPayload() []byte
- func (m *Message) GetQueue() string
- func (m *Message) GetReply() string
- func (m *Message) GetStatus() *google_rpc.Status
- func (m *Message) GetSubject() string
- func (m *Message) GetTimestamp() uint64
- func (*Message) ProtoMessage()
- func (m *Message) Reset()
- func (m *Message) String() string
- type PublishOption
- type PublishOptions
- type RequestOption
- type RequestOptions
- type SubscribeOption
- type SubscribeOptions
- type Transport
Constants ¶
This section is empty.
Variables ¶
var (
DefaultRequestTimeout = 2 * time.Second
)
Functions ¶
This section is empty.
Types ¶
type Handler ¶
Handler is the handler used by a subscriber. The return value may be nil if no output is yielded. If this is a request, the reply will be sent automatically with the reply value or an error if one occurred. If a reply is not expected and error occurs, it will be logged. The error can be inspected using status.FromError.
type Message ¶
type Message struct { // ID is a globally unique message. Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` // Timestamp is the timestamp in nanoseconds with the message was published. Timestamp uint64 `protobuf:"varint,2,opt,name=timestamp" json:"timestamp,omitempty"` // Payload is the actual payload being published that will be consumed. // This is expected to use protobuf encoding. Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` // Deprecated. Use status instead. Error string `protobuf:"bytes,4,opt,name=error" json:"error,omitempty"` // Cause is the ID of a message that resulted in this message being published. Cause string `protobuf:"bytes,5,opt,name=cause" json:"cause,omitempty"` // Subject is the subject the message is published. Subject string `protobuf:"bytes,6,opt,name=subject" json:"subject,omitempty"` // Queue is the queue this message was received by. Queue string `protobuf:"bytes,7,opt,name=queue" json:"queue,omitempty"` // Reply is the inbox ID of the publisher of this message. Reply string `protobuf:"bytes,8,opt,name=reply" json:"reply,omitempty"` // Error that occurs in during transport or in the application. Status *google_rpc.Status `protobuf:"bytes,9,opt,name=status" json:"status,omitempty"` }
Message is the envelope/wrapper for all messages.
func (*Message) Descriptor ¶
func (*Message) GetPayload ¶
func (*Message) GetStatus ¶
func (m *Message) GetStatus() *google_rpc.Status
func (*Message) GetSubject ¶
func (*Message) GetTimestamp ¶
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
type PublishOption ¶
type PublishOption func(*PublishOptions)
func PublishCause ¶
func PublishCause(s string) PublishOption
PublishCause sets the cause of the publication.
type PublishOptions ¶
type PublishOptions struct {
Cause string
}
PublishOptions are options for a publication.
type RequestOption ¶
type RequestOption func(*RequestOptions)
func RequestCause ¶
func RequestCause(s string) RequestOption
RequestCause sets the cause of the request.
func RequestTimeout ¶
func RequestTimeout(t time.Duration) RequestOption
RequestTimeout sets a request timeout duration.
type RequestOptions ¶
RequestOptions are options for a publication.
type SubscribeOption ¶
type SubscribeOption func(*SubscribeOptions)
func SubscribeQueue ¶
func SubscribeQueue(q string) SubscribeOption
SubscribeQueue specifies the queue name of the subscriber.
type SubscribeOptions ¶
type SubscribeOptions struct {
Queue string
}
SubscribeOptions are options for a subscriber.
type Transport ¶
type Transport interface { // Publish publishes a message asynchronously to the specified subject. // The wrapped message is returned or an error. The error would only be due to // a connection issue, but does not reflect any consumer error. Publish(sub string, msg proto.Message, opts ...PublishOption) (*Message, error) // Request publishes a message synchronously and waits for a response that // is decoded into the Protobuf message supplied. The wrapped message is // returned or an error. The error can inspected using status.FromError. Request(sub string, req proto.Message, rep proto.Message, opts ...RequestOption) (*Message, error) // Subscribe creates a subscription to a subject. Subscribe(sub string, hdl Handler, opts ...SubscribeOption) (*nats.Subscription, error) // Conn returns the underlying NATS connection. Conn() *nats.Conn // Close closes the transport connection and unsubscribes all subscribers. Close() // Set the logger. SetLogger(*zap.Logger) }
Transport describes the interface