autonats

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ServerStartTimeout = 5 * time.Minute

Variables

This section is empty.

Functions

func Connect

func Connect(hosts []string, secret string, opts ...nats.Option) (*nats.Conn, error)

func NewTLSConfig

func NewTLSConfig(secret string) (tlsc *tls.Config)

func WithAutoDialer

func WithAutoDialer(secret string) nats.Option

func WithDialFunc

func WithDialFunc(d func(network, address string) (net.Conn, error)) nats.Option

func WithSystemAccount

func WithSystemAccount() nats.Option

Types

type Logger

type Logger struct {
	*xlog.Logger
}

func (Logger) Debugf

func (l Logger) Debugf(format string, v ...any)

func (Logger) Errorf

func (l Logger) Errorf(format string, v ...any)

func (Logger) Fatalf

func (l Logger) Fatalf(format string, v ...any)

func (Logger) Noticef

func (l Logger) Noticef(format string, v ...any)

func (Logger) Tracef

func (l Logger) Tracef(format string, v ...any)

func (Logger) Warnf

func (l Logger) Warnf(format string, v ...any)

type Options

type Options struct {
	Debug       bool
	ServerName  string // Name of the server
	ClusterName string // Name of the cluster
	StoreDir    string // Directory to store data

	LocalAddr string // Address we bind to for strictly local connections
	LocalPort int    // Port to bind to for strictly local connections

	Addr      string // Address we bind to
	Advertise string // Address we advertise as
	Port      int    // Port to bind to for remote connections

	Secret    string       // Secret for interserver communication
	Logger    *xlog.Logger // Logger to use
	TLSConfig *tls.Config  // TLS configuration

	Topology Topology // Topology to use for bootstrapping
}

func (*Options) SetDefaults

func (opts *Options) SetDefaults()

type Server

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

func StartServer

func StartServer(opts Options) (srv *Server, err error)

func (*Server) ClientURL

func (s *Server) ClientURL() string

func (*Server) Close

func (s *Server) Close() error

func (*Server) Connect

func (s *Server) Connect(opts ...nats.Option) (*nats.Conn, error)

func (*Server) Done

func (s *Server) Done() <-chan struct{}

func (*Server) InProcessConn

func (s *Server) InProcessConn() (net.Conn, error)

func (*Server) Ready

func (s *Server) Ready() <-chan struct{}

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Server

func (s *Server) Server() *natssrv.Server

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

type Topology

type Topology map[string][]string // Cluster -> Hostname

func DiscoverTopologyConn

func DiscoverTopologyConn(ctx context.Context, conn *nats.Conn) (servers Topology, err error)

func ExpandSeedTopology

func ExpandSeedTopology(hosts []string, secret string, timeout time.Duration) (servers Topology, err error)

Jump to

Keyboard shortcuts

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