config

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package config is used for storing and manipulating (server) state in plumber. There should be, at most, a single instance of the plumber config that is passed around between various components.

Index

Constants

View Source
const (
	ConfigFilename = "config.json"
	KVConfigBucket = "plumber"
	KVConfigKey    = "persistent-config"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ClusterID string `json:"-"` // This comes from an environment variable
	PlumberID string `json:"plumber_id"`
	Token     string `json:"token"`
	TeamID    string `json:"team_id"`
	UserID    string `json:"user_id"`

	Connections         map[string]*stypes.Connection `json:"connections"`
	Relays              map[string]*stypes.Relay      `json:"relays"`
	Dynamic             map[string]*stypes.Dynamic    `json:"dynamic_replays"`
	ConnectionsMutex    *sync.RWMutex                 `json:"-"`
	RelaysMutex         *sync.RWMutex                 `json:"-"`
	DynamicReplaysMutex *sync.RWMutex                 `json:"-"`
	// contains filtered or unexported fields
}

Config stores Account IDs and the auth_token cookie

func New added in v1.3.0

func New(enableCluster bool, k kv.IKV) (*Config, error)

New will attempt to fetch and return an existing config from either NATS or the local disk. If neither are available, it will return a new config.

func (*Config) DeleteConnection

func (c *Config) DeleteConnection(connID string)

DeleteConnection removes a connection from in-memory map

func (*Config) DeleteDynamic added in v1.2.1

func (c *Config) DeleteDynamic(dynamicID string)

DeleteDynamic removes a dynamic replay from in-memory map

func (*Config) DeleteRelay

func (c *Config) DeleteRelay(relayID string)

DeleteRelay removes a service from in-memory map

func (*Config) GetConnection

func (c *Config) GetConnection(connID string) *stypes.Connection

GetConnection retrieves a connection from in-memory map

func (*Config) GetDynamic added in v1.2.1

func (c *Config) GetDynamic(dynamicID string) *stypes.Dynamic

GetDynamic returns an in-progress read from the Dynamic map

func (*Config) GetRelay

func (c *Config) GetRelay(relayID string) *stypes.Relay

GetRelay returns a relay from the in-memory map

func (*Config) Save

func (c *Config) Save() error

Save is a convenience method of persisting the config to KV store or disk

func (*Config) SetConnection

func (c *Config) SetConnection(connID string, conn *stypes.Connection)

SetConnection saves a connection to in-memory map

func (*Config) SetDynamic added in v1.2.1

func (c *Config) SetDynamic(dynamicID string, dynamicReplay *stypes.Dynamic)

SetDynamic adds an in-progress read to the Dynamic map

func (*Config) SetRelay

func (c *Config) SetRelay(relayID string, relay *stypes.Relay)

SetRelay saves a relay to in-memory map

func (*Config) Update added in v1.3.0

func (c *Config) Update(cfg *Config) error

Jump to

Keyboard shortcuts

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