config

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

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

If running in cluster mode, config will write the config to NATS. If running locally, the config will be saved to ~/.batchsh/plumber.json

Index

Constants

View Source
const (
	ConfigDir      = ".batchsh"
	ConfigFilename = "plumber.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"`
	EnableTelemetry bool   `json:"enable_telemetry"`
	LastVersion     string `json:"last_version"`

	Connections      map[string]*stypes.Connection `json:"connections"`
	Relays           map[string]*stypes.Relay      `json:"relays"`
	Tunnels          map[string]*stypes.Tunnel     `json:"tunnels"`
	ConnectionsMutex *sync.RWMutex                 `json:"-"`
	RelaysMutex      *sync.RWMutex                 `json:"-"`
	TunnelsMutex     *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) Configure added in v1.12.0

func (c *Config) Configure()

func (*Config) DeleteConnection

func (c *Config) DeleteConnection(connID string)

DeleteConnection removes a connection from in-memory map

func (*Config) DeleteRelay

func (c *Config) DeleteRelay(relayID string)

DeleteRelay removes a service from in-memory map

func (*Config) DeleteTunnel added in v1.4.0

func (c *Config) DeleteTunnel(tunnelID string)

DeleteTunnel removes a tunnel 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) GetRelay

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

GetRelay returns a relay from the in-memory map

func (*Config) GetTunnel added in v1.4.0

func (c *Config) GetTunnel(tunnelID string) *stypes.Tunnel

GetTunnel returns an in-progress read from the Tunnels 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) SetRelay

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

SetRelay saves a relay to in-memory map

func (*Config) SetTunnel added in v1.4.0

func (c *Config) SetTunnel(tunnelID string, tunnel *stypes.Tunnel)

SetTunnel adds an in-progress read to the Tunnels 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