Documentation ¶
Index ¶
- Constants
- Variables
- func NewNats(ctx context.Context, le *logrus.Entry, handler pubsub.PubSubHandler, ...) (pubsub.PubSub, error)
- type Config
- func (c *Config) ApplyOptions(opts *nats_server.Options) error
- func (m *Config) CloneGenericVT() proto.Message
- func (m *Config) CloneVT() *Config
- func (*Config) Descriptor() ([]byte, []int)deprecated
- func (this *Config) EqualVT(that *Config) bool
- func (x *Config) GetClusterName() string
- func (x *Config) GetLogDebug() bool
- func (x *Config) GetLogTrace() bool
- func (x *Config) GetLogTraceVerbose() bool
- func (x *Config) GetPublishHashType() hash.HashType
- func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *Config) MarshalToVT(dAtA []byte) (int, error)
- func (m *Config) MarshalVT() (dAtA []byte, err error)
- func (*Config) ProtoMessage()
- func (x *Config) ProtoReflect() protoreflect.Message
- func (x *Config) Reset()
- func (m *Config) SizeVT() (n int)
- func (x *Config) String() string
- func (m *Config) UnmarshalVT(dAtA []byte) error
- func (c *Config) Validate() error
- type KeyPair
- type Nats
- func (m *Nats) AddPeerStream(tpl pubsub.PeerLinkTuple, initiator bool, mstrm link.MountedStream)
- func (n *Nats) AddSubscription(ctx context.Context, privKey crypto.PrivKey, channelID string) (pubsub.Subscription, error)
- func (n *Nats) BuildClient(ctx context.Context, privKey crypto.PrivKey, opts ...nats_client.Option) (*nats_client.Conn, error)
- func (m *Nats) Close()
- func (m *Nats) Execute(ctx context.Context) error
- func (n *Nats) GetOrBuildCommonClient(ctx context.Context) (*nats_client.Conn, error)
- func (n *Nats) SubscribeSync(ctx context.Context, channelID string) (*nats_client.Subscription, *nats_client.Conn, error)
- type NatsConnType
- func (NatsConnType) Descriptor() protoreflect.EnumDescriptor
- func (x NatsConnType) Enum() *NatsConnType
- func (NatsConnType) EnumDescriptor() ([]byte, []int)deprecated
- func (x NatsConnType) Number() protoreflect.EnumNumber
- func (x NatsConnType) String() string
- func (NatsConnType) Type() protoreflect.EnumType
Constants ¶
const ( NatsRouterID = protocol.ID("nats.io/2/router") // nats 2.0 router NatsClientID = protocol.ID("nats.io/2/client") // nats 2.0 client API )
Variables ¶
var ( NatsConnType_name = map[int32]string{ 0: "NatsConnType_UNKNOWN", 1: "NatsConnType_CLIENT", 2: "NatsConnType_ROUTER", } NatsConnType_value = map[string]int32{ "NatsConnType_UNKNOWN": 0, "NatsConnType_CLIENT": 1, "NatsConnType_ROUTER": 2, } )
Enum value maps for NatsConnType.
var ( ErrInvalidLength = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflow = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroup = fmt.Errorf("proto: unexpected end of group") )
var File_github_com_aperturerobotics_bifrost_pubsub_nats_nats_proto protoreflect.FileDescriptor
Functions ¶
Types ¶
type Config ¶
type Config struct { // ClusterName is the cluster ID string to use. // This must be the same on all nodes. // If unset, uses the protocol ID. ClusterName string `protobuf:"bytes,1,opt,name=cluster_name,json=clusterName,proto3" json:"cluster_name,omitempty"` // PublishHashType is the hash type to use when signing published messages. // Defaults to sha256 PublishHashType hash.HashType `` /* 128-byte string literal not displayed */ // LogDebug turns on extended debugging logging. LogDebug bool `protobuf:"varint,3,opt,name=log_debug,json=logDebug,proto3" json:"log_debug,omitempty"` // LogTrace turns on tracing logging. // implies log_debug. LogTrace bool `protobuf:"varint,4,opt,name=log_trace,json=logTrace,proto3" json:"log_trace,omitempty"` // LogTraceVrebose turns on verbose tracing logging. // Implies log_trace and log_debug. LogTraceVerbose bool `protobuf:"varint,5,opt,name=log_trace_verbose,json=logTraceVerbose,proto3" json:"log_trace_verbose,omitempty"` // contains filtered or unexported fields }
Config configures the nats router, hosting a nats.io routing node. This uses nats 2.0 accounts - an Account maps to a Peer.
func (*Config) ApplyOptions ¶
func (c *Config) ApplyOptions(opts *nats_server.Options) error
ApplyOptions applies the nats server options.
func (*Config) CloneGenericVT ¶ added in v0.8.3
func (*Config) Descriptor
deprecated
func (*Config) GetClusterName ¶
func (*Config) GetLogDebug ¶
func (*Config) GetLogTrace ¶
func (*Config) GetLogTraceVerbose ¶
func (*Config) GetPublishHashType ¶
func (*Config) MarshalToSizedBufferVT ¶ added in v0.2.0
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
func (*Config) ProtoReflect ¶ added in v0.2.0
func (x *Config) ProtoReflect() protoreflect.Message
func (*Config) UnmarshalVT ¶ added in v0.2.0
type KeyPair ¶
type KeyPair struct {
// contains filtered or unexported fields
}
KeyPair wraps a Bifrost key pair.
func NewKeyPair ¶
NewKeyPair builds a new keypair. Public key must be specified unless private key is specified. Private key must be specified if public key is not.
func (*KeyPair) PrivateKey ¶
PrivateKey will return an error since this is not available for public key only KeyPairs.
func (*KeyPair) PublicKey ¶
PublicKey will return the encoded public key associated with the KeyPair. All KeyPairs have a public key.
func (*KeyPair) Sign ¶
Sign will return an error since this is not available for public key only KeyPairs.
type Nats ¶
type Nats struct {
// contains filtered or unexported fields
}
Nats implements the nats router.
func (*Nats) AddPeerStream ¶
func (m *Nats) AddPeerStream(tpl pubsub.PeerLinkTuple, initiator bool, mstrm link.MountedStream)
AddPeerStream adds a negotiated peer stream. Two streams will be negotiated, one outgoing, one incoming. The pubsub should communicate over the stream.
func (*Nats) AddSubscription ¶
func (n *Nats) AddSubscription(ctx context.Context, privKey crypto.PrivKey, channelID string) (pubsub.Subscription, error)
AddSubscription adds a channel subscription, returning a subscription handle.
Uses the router peer private key.
An alternate approach is to use a client connection.
func (*Nats) BuildClient ¶
func (n *Nats) BuildClient(ctx context.Context, privKey crypto.PrivKey, opts ...nats_client.Option) (*nats_client.Conn, error)
BuildClient builds a client for the nats server, creating a client connection.
Note: the servers list & dialer will be overwritten.
func (*Nats) GetOrBuildCommonClient ¶
GetOrBuildCommonClient returns the common nats client.
func (*Nats) SubscribeSync ¶
func (n *Nats) SubscribeSync( ctx context.Context, channelID string, ) (*nats_client.Subscription, *nats_client.Conn, error)
SubscribeSync passes through to the nats client SubscribeSync call.
type NatsConnType ¶
type NatsConnType int32
NatsConnType indicates the type of nats conn a stream represents.
const ( // NatsConnType_UNKNOWN is the unknown type. NatsConnType_NatsConnType_UNKNOWN NatsConnType = 0 // NatsConnType_CLIENT is the client connection type. NatsConnType_NatsConnType_CLIENT NatsConnType = 1 // NatsConnType_ROUTER is the router-router connection type. NatsConnType_NatsConnType_ROUTER NatsConnType = 2 // TODO other types )
func ProtocolIDToStreamType ¶
func ProtocolIDToStreamType(id protocol.ID) NatsConnType
ProtocolIDToStreamType converts a protocol ID to a conn type.
func (NatsConnType) Descriptor ¶ added in v0.2.0
func (NatsConnType) Descriptor() protoreflect.EnumDescriptor
func (NatsConnType) Enum ¶ added in v0.2.0
func (x NatsConnType) Enum() *NatsConnType
func (NatsConnType) EnumDescriptor
deprecated
func (NatsConnType) EnumDescriptor() ([]byte, []int)
Deprecated: Use NatsConnType.Descriptor instead.
func (NatsConnType) Number ¶ added in v0.2.0
func (x NatsConnType) Number() protoreflect.EnumNumber
func (NatsConnType) String ¶
func (x NatsConnType) String() string
func (NatsConnType) Type ¶ added in v0.2.0
func (NatsConnType) Type() protoreflect.EnumType