nats

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2022 License: AGPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNatsServerInfos added in v0.5.2

func GetNatsServerInfos() (*api.ServerInformationResponse, error)

GetNatsServerInfos returns the nats server information

func NewCreds

func NewCreds(jwt string, nkey string) string

NewCreds creates a new nats creds file

Types

type Authorization

type Authorization struct {
	Users []User `json:"users,omitempty"`
}

Authorization is the authorization configuration

type Config

type Config struct {
	Jetstream       *Jetstream     `json:"jetstream,omitempty"`
	Authorization   *Authorization `json:"authorization,omitempty"`
	PidFile         *string        `json:"pid_file,omitempty"`
	HTTP            int            `json:"http"`
	Leafnodes       *Leafnodes     `json:"leafnodes,omitempty"`
	Operator        *string        `json:"operator,omitempty"`
	SystemAccount   *string        `json:"system_account,omitempty"`
	Resolver        *Resolver      `json:"resolver,omitempty"`
	ResolverPreload interface{}    `json:"resolver_preload,omitempty"`
}

Config is the configuration for the NATS server

func LoadFromFile

func LoadFromFile(path string) (*Config, error)

LoadFromFile loads a config ftom a JSON file

func LoadFromJSON

func LoadFromJSON(j string) (*Config, error)

LoadFromJSON loads a config from a JSON string

func NewConfig

func NewConfig(opts ...Option) *Config

NewConfig creates a new Config instance

func (*Config) AddNGSRemote

func (c *Config) AddNGSRemote(credentials string, accountPublicKey string, denyImports []string, denyExports []string) error

AddNGSRemote adds a NGS remote to the config

func (*Config) AddRemote

func (c *Config) AddRemote(url string, credentials string, accountPublicKey string, denyImports []string, denyExports []string) error

AddRemote adds a remote to the configs

func (*Config) RemoveRemoteByAccountPubKey

func (c *Config) RemoveRemoteByAccountPubKey(accountPublicKey string) error

RemoveRemoteByAccountPubKey removes a remote by account public key

func (*Config) RemoveRemoteByCredsfile

func (c *Config) RemoveRemoteByCredsfile(path string) error

RemoveRemoteByCredsfile removes a remote by credentials files path

func (*Config) ToJSON

func (c *Config) ToJSON() (string, error)

ToJSON converts a Config instance to Json

type Jetstream added in v0.5.2

type Jetstream struct {
	StoreDir string `json:"store_dir"`
	Domain   string `json:"domain"`
}

Jetstream is the jetstream configuration for the NATS server

type Leafnodes

type Leafnodes struct {
	Remotes []Remotes `json:"remotes"`
}

Leafnodes is the leafnode configuration part

type Option

type Option func(*Config)

Option is a type that represents a Config option

func WithAdminUser

func WithAdminUser(user string, password string) Option

WithAdminUser sets an admin user

func WithCacheResolver

func WithCacheResolver(operatorJWT string, sysAccountPubKey string, sysAccountJWT string, jwtStoragePath string) Option

WithCacheResolver sets a cached resolver (used for leaf nats servers)

func WithFullResolver

func WithFullResolver(operatorJWT string, sysAccountPubKey string, sysAccountJWT string, jwtStoragePath string) Option

WithFullResolver sets a full resolver (used for nats account servers)

func WithJetstream added in v0.5.2

func WithJetstream(storageDir string, domain string) Option

WithJetstream enabled jetstream and sets the store dir and an domain

func WithNGSRemote

func WithNGSRemote(credentials string, accountPublicKey string, denyImports []string, denyExports []string) Option

WithNGSRemote sets a leafnode remote to NGS

func WithPidFile

func WithPidFile(pidFile string) Option

WithPidFile sets a leafnode remote

func WithRemote

func WithRemote(url string, credentials string, accountPublicKey string, denyImports []string, denyExports []string) Option

WithRemote sets a leafnode remote

type Remotes

type Remotes struct {
	// URL is the remote url, e.g. tls://connect.ngs.global:7422 or nats://localhost:4222
	URL string `json:"url"`
	// Path to creds file
	Credentials string `json:"credentials"`
	// Account public key
	Account string `json:"account"`
	// DenyImports is a list of subjects to deny imports for
	DenyImports []string `json:"deny_imports,omitempty"`
	// DenyExports is a list of subjects to deny exports for
	DenyExports []string `json:"deny_exports,omitempty"`
}

Remotes is the remote configuration part

type Resolver

type Resolver struct {
	Type        string  `json:"type"`
	Dir         string  `json:"dir"`
	AllowDelete *bool   `json:"allow_delete,omitempty"`
	Interval    *string `json:"interval,omitempty"`
	TTL         *string `json:"ttl,omitempty"`
	Timeout     string  `json:"timeout"`
}

Resolver is the resolver configuration part

type User

type User struct {
	User     string `json:"user"`
	Password string `json:"password"`
}

User contains the user information

Jump to

Keyboard shortcuts

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