discovery

package
v0.0.0-...-be0919c Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2018 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BrokerPort          = 4222
	BrokerMaxReconnect  = -1
	BrokerReconnectWait = 4 * time.Second
	BrokerTimeout       = 5 * time.Second
)

Broker Constants

View Source
const TypeContactNATSV1 = "nats/v1"

TypeContactNATSV1 defines V1 format for NATS contact

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap()

Bootstrap loads NATS discovery package into the overall system

Types

type AddressNATS

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

AddressNATS structure defines details how NATS connection can be established

func NewAddress

func NewAddress(topic string, addresses ...string) *AddressNATS

NewAddress creates NATS address to known host or cluster of hosts

func NewAddressForContact

func NewAddressForContact(contact dto_discovery.Contact) (*AddressNATS, error)

NewAddressForContact extracts NATS address from given contact structure

func NewAddressGenerate

func NewAddressGenerate(brokerIP string, myID identity.Identity) *AddressNATS

NewAddressGenerate generates NATS address for current node

func NewAddressWithConnection

func NewAddressWithConnection(connection nats.Connection, topic string) *AddressNATS

NewAddressWithConnection constructs NATS address to already active NATS connection

func (*AddressNATS) Connect

func (address *AddressNATS) Connect() (err error)

Connect establishes connection to broker

func (*AddressNATS) Disconnect

func (address *AddressNATS) Disconnect()

Disconnect stops currently established connection

func (*AddressNATS) GetConnection

func (address *AddressNATS) GetConnection() nats.Connection

GetConnection returns currently established connection

func (*AddressNATS) GetContact

func (address *AddressNATS) GetContact() dto_discovery.Contact

GetContact serializes current address to Contact structure.

func (*AddressNATS) GetTopic

func (address *AddressNATS) GetTopic() string

GetTopic returns topic. Address points to this topic in established connection.

type ContactNATSV1

type ContactNATSV1 struct {
	// Topic on which client is getting message
	Topic string `json:"topic"`
	// NATS servers used by node and should be contacted via
	BrokerAddresses []string `json:"broker_addresses"`
}

ContactNATSV1 is definition of NATS contact

Jump to

Keyboard shortcuts

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