mbus

package
v0.0.0-...-a602bb6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: Apache-2.0, BSD-2-Clause-Views, BSD-3-Clause, + 1 more Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(c *config.Config, reconnected chan<- Signal, l *slog.Logger) *nats.Conn

Types

type Client

type Client interface {
	Subscribe(subj string, cb nats.MsgHandler) (*nats.Subscription, error)
	Publish(subj string, data []byte) error
}

type RegistryMessage

type RegistryMessage struct {
	App                     string              `json:"app"`
	AvailabilityZone        string              `json:"availability_zone"`
	EndpointUpdatedAtNs     int64               `json:"endpoint_updated_at_ns"`
	Host                    string              `json:"host"`
	IsolationSegment        string              `json:"isolation_segment"`
	Port                    uint16              `json:"port"`
	PrivateInstanceID       string              `json:"private_instance_id"`
	PrivateInstanceIndex    string              `json:"private_instance_index"`
	Protocol                string              `json:"protocol"`
	RouteServiceURL         string              `json:"route_service_url"`
	ServerCertDomainSAN     string              `json:"server_cert_domain_san"`
	StaleThresholdInSeconds int                 `json:"stale_threshold_in_seconds"`
	TLSPort                 uint16              `json:"tls_port"`
	Tags                    map[string]string   `json:"tags"`
	Uris                    []route.Uri         `json:"uris"`
	Options                 RegistryMessageOpts `json:"options"`
}

func (*RegistryMessage) ValidateMessage

func (rm *RegistryMessage) ValidateMessage() bool

ValidateMessage checks to ensure the registry message is valid

type RegistryMessageOpts

type RegistryMessageOpts struct {
	LoadBalancingAlgorithm string `json:"loadbalancing"`
}

type Signal

type Signal struct{}

type Subscriber

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

Subscriber subscribes to NATS for all router.* messages and handles them

func NewSubscriber

func NewSubscriber(
	mbusClient Client,
	routeRegistry registry.Registry,
	c *config.Config,
	reconnected <-chan Signal,
	l *slog.Logger,
) *Subscriber

NewSubscriber returns a new Subscriber

func (*Subscriber) Dropped

func (s *Subscriber) Dropped() (int, error)

func (*Subscriber) Pending

func (s *Subscriber) Pending() (int, error)

func (*Subscriber) Run

func (s *Subscriber) Run(signals <-chan os.Signal, ready chan<- struct{}) error

Run manages the lifecycle of the subscriber process

Source Files

  • client.go
  • subscriber.go

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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