nats

package
v2.0.0-preview4 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Overview

Package nats implements the CloudEvent transport implementation using NATS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteMsg

func WriteMsg(ctx context.Context, m binding.Message, natsMessage *nats.Msg, transformers ...binding.TransformerFactory) error

Fill the provided natsMessage with the bindings.Message m. Using context you can tweak the encoding processing (more details on binding.Write documentation).

Types

type Message

type Message struct {
	Msg *nats.Msg
	// contains filtered or unexported fields
}

Message implements binding.Message by wrapping an *nats.Msg. This message *can* be read several times safely

func NewMessage

func NewMessage(msg *nats.Msg) *Message

Wrap an *nats.Msg in a binding.Message. The returned message *can* be read several times safely

func (*Message) Finish

func (m *Message) Finish(err error) error

func (*Message) ReadBinary

func (m *Message) ReadBinary(ctx context.Context, encoder binding.BinaryWriter) error

func (*Message) ReadEncoding

func (m *Message) ReadEncoding() binding.Encoding

func (*Message) ReadStructured

func (m *Message) ReadStructured(ctx context.Context, encoder binding.StructuredWriter) error

type Option

type Option func(*Protocol) error

Option is the function signature required to be considered an nats.Option.

func WithConnOptions

func WithConnOptions(opts ...nats.Option) Option

WithConnOptions supplies NATS connection options that will be used when setting up the internal NATS connection

func WithTransformer

func WithTransformer(transformer binding.TransformerFactory) Option

Add a transformer, which Protocol uses while encoding a binding.Message to an nats.Message

type Protocol

type Protocol struct {
	Conn         *nats.Conn
	ConnOptions  []nats.Option
	NatsURL      string
	Subject      string
	Transformers binding.TransformerFactories
	// contains filtered or unexported fields
}

Protocol is a reference implementation for using the CloudEvents binding integration. Protocol acts as both a NATS client and a NATS handler.

func New

func New(natsURL, subject string, opts ...Option) (*Protocol, error)

New creates a new NATS protocol.

func (*Protocol) Close

func (t *Protocol) Close(ctx context.Context) error

Close implements Closer.Close

func (*Protocol) Receive

func (t *Protocol) Receive(ctx context.Context) (binding.Message, error)

Receive implements Receiver.Receive

func (*Protocol) Send

func (t *Protocol) Send(ctx context.Context, in binding.Message) error

Send implements Sender.Send

Jump to

Keyboard shortcuts

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