nats

package
v2.0.0-...-be496b8 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Server          string = "nats-server"  // Server specifies the Nats server Address
	Subject         string = "nats-subject" // Subject specifies the NATs subject
	ApplicationName        = "app_name"     // ApplicationName specifies the application name. This often matches the actor system name
	Timeout                = "timeout"      // Timeout specifies the discovery timeout. The default value is 1 second
)

Variables

View Source
var (
	MessageType_name = map[int32]string{
		0: "MESSAGE_TYPE_REGISTER",
		1: "MESSAGE_TYPE_DEREGISTER",
		2: "MESSAGE_TYPE_REQUEST",
		3: "MESSAGE_TYPE_RESPONSE",
	}
	MessageType_value = map[string]int32{
		"MESSAGE_TYPE_REGISTER":   0,
		"MESSAGE_TYPE_DEREGISTER": 1,
		"MESSAGE_TYPE_REQUEST":    2,
		"MESSAGE_TYPE_RESPONSE":   3,
	}
)

Enum value maps for MessageType.

Functions

This section is empty.

Types

type Discovery

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

Discovery represents the kubernetes discovery

func NewDiscovery

func NewDiscovery(opts ...Option) *Discovery

NewDiscovery returns an instance of the kubernetes discovery provider

func (*Discovery) Close

func (d *Discovery) Close() error

Close closes the provider

func (*Discovery) Deregister

func (d *Discovery) Deregister() error

Deregister removes this node from a service discovery directory.

func (*Discovery) DiscoverNodes

func (d *Discovery) DiscoverNodes() ([]*discovery.Node, error)

DiscoverNodes returns a list of known nodes.

func (*Discovery) ID

func (d *Discovery) ID() string

ID returns the discovery provider id

func (*Discovery) Initialize

func (d *Discovery) Initialize() error

Initialize initializes the plugin: registers some internal data structures, clients etc.

func (*Discovery) Register

func (d *Discovery) Register() error

Register registers this node to a service discovery directory.

func (*Discovery) SetConfig

func (d *Discovery) SetConfig(config discovery.Options) error

SetConfig registers the underlying discovery configuration

func (*Discovery) Watch

func (d *Discovery) Watch(ctx context.Context) (<-chan discovery.Event, error)

Watch returns event based upon node lifecycle

type Message

type Message struct {

	// Specifies the host name of the client node
	Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"`
	// Specifies the port of the client node
	Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"`
	// Specifies the client name
	Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
	// Specifies the message type
	MessageType MessageType `protobuf:"varint,4,opt,name=message_type,json=messageType,proto3,enum=nats.MessageType" json:"message_type,omitempty"`
	// contains filtered or unexported fields
}

Message defines the NATs message used by the discovery provider

func (*Message) Descriptor deprecated

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

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetHost

func (x *Message) GetHost() string

func (*Message) GetMessageType

func (x *Message) GetMessageType() MessageType

func (*Message) GetName

func (x *Message) GetName() string

func (*Message) GetPort

func (x *Message) GetPort() int32

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect

func (x *Message) ProtoReflect() protoreflect.Message

func (*Message) Reset

func (x *Message) Reset()

func (*Message) String

func (x *Message) String() string

type MessageType

type MessageType int32

MessageType defines the NATs message type

const (
	MessageType_MESSAGE_TYPE_REGISTER   MessageType = 0
	MessageType_MESSAGE_TYPE_DEREGISTER MessageType = 1
	MessageType_MESSAGE_TYPE_REQUEST    MessageType = 2
	MessageType_MESSAGE_TYPE_RESPONSE   MessageType = 3
)

func (MessageType) Descriptor

func (MessageType) Enum

func (x MessageType) Enum() *MessageType

func (MessageType) EnumDescriptor deprecated

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

Deprecated: Use MessageType.Descriptor instead.

func (MessageType) Number

func (x MessageType) Number() protoreflect.EnumNumber

func (MessageType) String

func (x MessageType) String() string

func (MessageType) Type

type Option

type Option interface {
	// Apply sets the Option value of a config.
	Apply(disco *Discovery)
}

Option is the interface that applies a configuration option.

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger sets the logger

type OptionFunc

type OptionFunc func(disco *Discovery)

OptionFunc implements the Option interface.

func (OptionFunc) Apply

func (f OptionFunc) Apply(disco *Discovery)

Apply applies the Cluster's option

Jump to

Keyboard shortcuts

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