standriver

package
v0.0.0-...-22ff681 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	HealthCheckerCreated bool
	Reconnected          bool
	// contains filtered or unexported fields
}

Connection holds NATS and NATS-Streaming(STAN) connections. It's fields are meant to be read-only, so you should not write to them. To create a new Connection, you must use the standriver.New(...) function. Instantiating a Connection literal or using go's new() function may lead to undefined behavior.

func New

func New(URLs []string, ClusterID string, ClientID string) *Connection

New creates a new Connection

func (*Connection) Close

func (n *Connection) Close() (err error)

Close closes NATS and STAN connections

func (*Connection) Connect

func (n *Connection) Connect() (err error)

Connect connects to NATS and STAN, initializing their corresponding variables

func (*Connection) Publish

func (n *Connection) Publish(subject string, message []byte) (err error)

Publish publishes the message with subject

func (*Connection) Reconnect

func (n *Connection) Reconnect() (err error)

Reconnect closes STAN connection and connects again

func (*Connection) Subscribe

func (n *Connection) Subscribe(sf SubscriberFunc)

Subscribe takes a SubscriberFunc sf and invokes it, and also makes sure it is called every time STAN is reconnected. This means subscriptions persist through STAN reconnects. SubscriberFunc is a function which performs your subscriptions to a stan.Conn object.

type ConnectionInterface

type ConnectionInterface interface {
	Connect() error
	Reconnect() error
	AutoReconnect(interval time.Duration, stop chan struct{})
	Close() error
}

type SubscriberFunc

type SubscriberFunc func(sc stan.Conn)

SubscribeFunc takes a STAN connection and subscribes anything it wants to it.

Jump to

Keyboard shortcuts

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