config

package
v0.0.0-...-f4dfc87 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2016 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const REDIS_PORT = "6379"
View Source
const SUB_TTL = 10 * time.Second

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface{}

Type-checked JSON-serializeable config object

type ConfigMap

type ConfigMap map[string]interface{}

Generic JSON config object

type ConfigPush

type ConfigPush struct {
	// this needs to be a pointer for .MarshalJSON()
	Config *json.RawMessage `json:"config,omitempty"`
	// contains filtered or unexported fields
}

func (ConfigPush) ApplyFunc

func (self ConfigPush) ApplyFunc(applyFunc func(ConfigPush) (Config, error))

func (ConfigPush) Reject

func (self ConfigPush) Reject(err error)

func (ConfigPush) Unmarshal

func (self ConfigPush) Unmarshal(config interface{}) error

type ConfigReturn

type ConfigReturn struct {
	ID     ID     `json:"id"`
	Error  error  `json:"error,omitempty"`
	Config Config `json:"config,omitempty"`
}

type ID

type ID struct {
	Type     string `json:"type"`
	Instance string `json:"instance"`
}

func ParseID

func ParseID(subType string, instance string) (ID, error)

func (ID) Check

func (self ID) Check() error

Return error if not Valid()

func (ID) String

func (self ID) String() string

func (ID) Valid

func (self ID) Valid() bool

type Options

type Options struct {
	RedisURL RedisURL      `long:"redis-url" value-name:"tcp://[:PASSWORD@]HOST[:PORT][/PREFIX]" env:"REDIS_URL"`
	Timeout  time.Duration `long:"redis-timeout" value-name:"DURATION" default:"10s"`
}

func (Options) Empty

func (self Options) Empty() bool

type Redis

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

func NewRedis

func NewRedis(options Options) (*Redis, error)

func (*Redis) GetSub

func (self *Redis) GetSub(id ID) (*Sub, error)

Get an existing sub may not necessarily be active yet!

func (*Redis) List

func (self *Redis) List(subType string) (subs []*Sub, err error)

List all Subs, for given type

func (*Redis) ListTypes

func (self *Redis) ListTypes() ([]string, error)

List all types

func (*Redis) NewSub

func (self *Redis) NewSub(subType string, instance string) (*Sub, error)

Return a new Sub for the given name

func (*Redis) String

func (self *Redis) String() string

type RedisURL

type RedisURL url.URL

func (RedisURL) Empty

func (self RedisURL) Empty() bool

func (*RedisURL) MarshalFlag

func (self *RedisURL) MarshalFlag() (string, error)

func (RedisURL) Prefix

func (self RedisURL) Prefix() string

func (RedisURL) RedisOptions

func (self RedisURL) RedisOptions() (redisOptions redis.Options)

TODO: ?db=

func (RedisURL) String

func (self RedisURL) String() string

func (*RedisURL) UnmarshalFlag

func (self *RedisURL) UnmarshalFlag(value string) error

type Sub

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

func (*Sub) Check

func (self *Sub) Check() (time.Duration, error)

Check if this sub still exists, and return remaining TTL

func (*Sub) Get

func (self *Sub) Get() (ConfigMap, error)

get as generic map[string]interface{} includes additional _fields for SubOptions

func (*Sub) ID

func (self *Sub) ID() ID

func (*Sub) Push

func (self *Sub) Push(config Config) error

update (partial) params for sub return an error if there is no active sub

func (*Sub) Register

func (self *Sub) Register(config Config) error

Register.

func (*Sub) Start

func (self *Sub) Start(config Config) (chan ConfigPush, error)

Register ourselves in redis, storing the given Config.

Receive ConfigPush's from redis, and store the updated Config into redis.

func (*Sub) String

func (self *Sub) String() string

type SubOptions

type SubOptions struct {
	Options
	Instance string `long:"config-instance" env:"CLOSE_INSTANCE"`
}

Jump to

Keyboard shortcuts

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