registry

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Leafnodes

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

type NatsConfig

type NatsConfig struct {
	PidFile   string    `json:"pid_file"`
	Http      int       `json:"http"`
	Leafnodes Leafnodes `json:"leafnodes"`
}

func NewJson

func NewJson(path string) *NatsConfig

func (*NatsConfig) Dump

func (c *NatsConfig) Dump() string

type Registry

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

Registry is a registry for nats-leafnodes

func NewRegistry

func NewRegistry(natsConfig string, creds string, natsURI string, state string) (*Registry, error)

NewRegistry creates a new registry

func (*Registry) Config

func (r *Registry) Config() string

Config returns the current configuration as a JSON string

func (*Registry) Shutdown

func (r *Registry) Shutdown()

Shutdown shuts down the registry

func (*Registry) Start

func (r *Registry) Start() error

Start starts the registry and handles all incoming requests for registering and unregistering

type Remote

type Remote struct {
	Url         string `json:"url"`
	Credentials string `json:"credentials"`
}

type State

type State struct {
	// Path to the state file
	Path string
	// Current state
	Current current
}

State is a struct that holds the state of the registry

func NewState

func NewState(path string) *State

NewState creates a new state

func (*State) CanDelete

func (s *State) CanDelete(network string) (bool, error)

CanDelete checks whether the network can be deleted

func (*State) Delete

func (s *State) Delete(network string) error

Delete deletes the network from the state

func (*State) Read

func (s *State) Read() error

Read reads the state from the file

func (*State) Save

func (s *State) Save() error

Save saves the state to the file

func (*State) Update

func (s *State) Update(network string, component string, action UpdateAction) error

Update updates the state.

func (*State) Usage

func (s *State) Usage(network string) (int, error)

Usage returns the usage count of the network

type UpdateAction

type UpdateAction string

UpdateAction is an enum for the update action

const (
	// Add is the action for adding a component to the state
	Add UpdateAction = "add"
	// Remove is the action for removing a component from the state
	Remove UpdateAction = "remove"
)

Jump to

Keyboard shortcuts

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