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) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *Config) CloneVT() *Config
- func (this *Config) EqualMessageVT(thatMsg any) bool
- 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 (x *Config) MarshalJSON() ([]byte, error)
- func (x *Config) MarshalProtoJSON(s *json.MarshalState)
- func (x *Config) MarshalProtoText() string
- 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) Reset()
- func (m *Config) SizeVT() (n int)
- func (x *Config) String() string
- func (x *Config) UnmarshalJSON(b []byte) error
- func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)
- 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 (x NatsConnType) Enum() *NatsConnType
- func (x NatsConnType) MarshalJSON() ([]byte, error)
- func (x NatsConnType) MarshalProtoJSON(s *json.MarshalState)
- func (x NatsConnType) MarshalProtoText() string
- func (x NatsConnType) MarshalText() ([]byte, error)
- func (x NatsConnType) String() string
- func (x *NatsConnType) UnmarshalJSON(b []byte) error
- func (x *NatsConnType) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (x *NatsConnType) UnmarshalText(b []byte) error
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.
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:"clusterName,omitempty"` // PublishHashType is the hash type to use when signing published messages. // Defaults to sha256 PublishHashType hash.HashType `protobuf:"varint,2,opt,name=publish_hash_type,json=publishHashType,proto3" json:"publishHashType,omitempty"` // LogDebug turns on extended debugging logging. LogDebug bool `protobuf:"varint,3,opt,name=log_debug,json=logDebug,proto3" json:"logDebug,omitempty"` // LogTrace turns on tracing logging. // implies log_debug. LogTrace bool `protobuf:"varint,4,opt,name=log_trace,json=logTrace,proto3" json:"logTrace,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:"logTraceVerbose,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) CloneMessageVT ¶ added in v0.15.6
func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*Config) EqualMessageVT ¶ added in v0.15.6
func (*Config) GetClusterName ¶
func (*Config) GetLogDebug ¶
func (*Config) GetLogTrace ¶
func (*Config) GetLogTraceVerbose ¶
func (*Config) GetPublishHashType ¶
func (*Config) MarshalJSON ¶ added in v0.29.0
MarshalJSON marshals the Config to JSON.
func (*Config) MarshalProtoJSON ¶ added in v0.29.0
func (x *Config) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the Config message to JSON.
func (*Config) MarshalProtoText ¶ added in v0.29.2
func (*Config) MarshalToSizedBufferVT ¶ added in v0.2.0
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
func (*Config) UnmarshalJSON ¶ added in v0.29.0
UnmarshalJSON unmarshals the Config from JSON.
func (*Config) UnmarshalProtoJSON ¶ added in v0.29.0
func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the Config message from JSON.
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) Enum ¶ added in v0.2.0
func (x NatsConnType) Enum() *NatsConnType
func (NatsConnType) MarshalJSON ¶ added in v0.29.0
func (x NatsConnType) MarshalJSON() ([]byte, error)
MarshalJSON marshals the NatsConnType to JSON.
func (NatsConnType) MarshalProtoJSON ¶ added in v0.29.0
func (x NatsConnType) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the NatsConnType to JSON.
func (NatsConnType) MarshalProtoText ¶ added in v0.29.2
func (x NatsConnType) MarshalProtoText() string
func (NatsConnType) MarshalText ¶ added in v0.29.0
func (x NatsConnType) MarshalText() ([]byte, error)
MarshalText marshals the NatsConnType to text.
func (NatsConnType) String ¶
func (x NatsConnType) String() string
func (*NatsConnType) UnmarshalJSON ¶ added in v0.29.0
func (x *NatsConnType) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the NatsConnType from JSON.
func (*NatsConnType) UnmarshalProtoJSON ¶ added in v0.29.0
func (x *NatsConnType) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the NatsConnType from JSON.
func (*NatsConnType) UnmarshalText ¶ added in v0.29.0
func (x *NatsConnType) UnmarshalText(b []byte) error
UnmarshalText unmarshals the NatsConnType from text.