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
- type Config
- func (c *Config) DeleteConnection(connID string)
- func (c *Config) DeleteDynamic(dynamicID string)
- func (c *Config) DeleteRelay(relayID string)
- func (c *Config) GetConnection(connID string) *stypes.Connection
- func (c *Config) GetDynamic(dynamicID string) *stypes.Dynamic
- func (c *Config) GetRelay(relayID string) *stypes.Relay
- func (c *Config) Save() error
- func (c *Config) SetConnection(connID string, conn *stypes.Connection)
- func (c *Config) SetDynamic(dynamicID string, dynamicReplay *stypes.Dynamic)
- func (c *Config) SetRelay(relayID string, relay *stypes.Relay)
- func (c *Config) Update(cfg *Config) error
Constants ¶
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
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 ¶
DeleteConnection removes a connection from in-memory map
func (*Config) DeleteDynamic ¶ added in v1.2.1
DeleteDynamic removes a dynamic replay from in-memory map
func (*Config) DeleteRelay ¶
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
GetDynamic returns an in-progress read from the Dynamic map
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
SetDynamic adds an in-progress read to the Dynamic map