Documentation
¶
Index ¶
- Constants
- func GetStateDriver() (types.StateDriver, error)
- func InitializeStateDriver(dataStoreDriver, dataStoreAddress string) error
- func NewStateDriver(name string, config *types.KVStoreConfig) (types.StateDriver, error)
- type ConsulStateDriver
- func (d *ConsulStateDriver) Clear(key string) error
- func (d *ConsulStateDriver) ClearState(key string) error
- func (d *ConsulStateDriver) Deinit()
- func (d *ConsulStateDriver) Init(config *types.KVStoreConfig) error
- func (d *ConsulStateDriver) Mkdir(key string) error
- func (d *ConsulStateDriver) Read(key string) ([]byte, error)
- func (d *ConsulStateDriver) ReadAll(baseKey string) ([][]byte, error)
- func (d *ConsulStateDriver) ReadAllState(baseKey string, sType types.State, unmarshal func([]byte, interface{}) error) ([]types.State, error)
- func (d *ConsulStateDriver) ReadState(key string, value types.State, unmarshal func([]byte, interface{}) error) error
- func (d *ConsulStateDriver) WatchAll(baseKey string, chValueChanges chan [2][]byte) error
- func (d *ConsulStateDriver) WatchAllState(baseKey string, sType types.State, unmarshal func([]byte, interface{}) error, ...) error
- func (d *ConsulStateDriver) Write(key string, value []byte) error
- func (d *ConsulStateDriver) WriteState(key string, value types.State, marshal func(interface{}) ([]byte, error)) error
- type EtcdStateDriver
- func (d *EtcdStateDriver) Clear(key string) error
- func (d *EtcdStateDriver) ClearState(key string) error
- func (d *EtcdStateDriver) Deinit()
- func (d *EtcdStateDriver) Init(config *types.KVStoreConfig) error
- func (d *EtcdStateDriver) Mkdir(key string) error
- func (d *EtcdStateDriver) Read(key string) ([]byte, error)
- func (d *EtcdStateDriver) ReadAll(baseKey string) ([][]byte, error)
- func (d *EtcdStateDriver) ReadAllState(baseKey string, sType types.State, unmarshal func([]byte, interface{}) error) ([]types.State, error)
- func (d *EtcdStateDriver) ReadState(key string, value types.State, unmarshal func([]byte, interface{}) error) error
- func (d *EtcdStateDriver) WatchAll(baseKey string, chValueChanges chan [2][]byte) error
- func (d *EtcdStateDriver) WatchAllState(baseKey string, sType types.State, unmarshal func([]byte, interface{}) error, ...) error
- func (d *EtcdStateDriver) Write(key string, value []byte) error
- func (d *EtcdStateDriver) WriteState(key string, value types.State, marshal func(interface{}) ([]byte, error)) error
Constants ¶
const ( // EtcdName is a string constant for etcd state-store EtcdName = "etcd" // ConsulName is a string constant for consul state-store ConsulName = "consul" )
Variables ¶
This section is empty.
Functions ¶
func GetStateDriver ¶
func GetStateDriver() (types.StateDriver, error)
GetStateDriver returns the singleton instance of state-driver return values:
types.StateDriver: if its already instantiated error: auth_errors.ErrStateDriverNotCreated
func InitializeStateDriver ¶
InitializeStateDriver initializes the state driver based on the given data store address params:
dataStoreAddress: address of the data store
return values:
returns any error as NewStateDriver() + validation errors
func NewStateDriver ¶
func NewStateDriver(name string, config *types.KVStoreConfig) (types.StateDriver, error)
NewStateDriver instantiates a 'named' state-driver with specified configuration params:
name: Name of the state driver. e.g. `etcd` or `consul` config: configuration required to instantiate state driver
return values:
returns types.StateDriver on successful instantiation or any relevant error
Types ¶
type ConsulStateDriver ¶
ConsulStateDriver implements the StateDriver interface for a consul-based distributed key-value store used to store any state information needed by auth_proxy
func (*ConsulStateDriver) Clear ¶
func (d *ConsulStateDriver) Clear(key string) error
Clear clears the value for a key in consul
Parameters:
key: key for which value is to be cleared
Return value:
error: Error returned by consul client when deleting a key
func (*ConsulStateDriver) ClearState ¶
func (d *ConsulStateDriver) ClearState(key string) error
ClearState clears the state for a key in consul
Parameters:
key: key for which state is to be cleared
Return value:
error: Error returned by consul client when deleting a key
func (*ConsulStateDriver) Deinit ¶
func (d *ConsulStateDriver) Deinit()
Deinit is currently a no-op.
func (*ConsulStateDriver) Init ¶
func (d *ConsulStateDriver) Init(config *types.KVStoreConfig) error
Init initializes the state driver with needed configuration
Parameters:
config: configuration parameters to create consul client
Return values:
error: error when creating a consul client
func (*ConsulStateDriver) Mkdir ¶
func (d *ConsulStateDriver) Mkdir(key string) error
Mkdir creates a directory. If it already exists, this is a no-op.
Parameters:
key: target directory path (must have trailing slash and not begin with a slash)
Return values:
error: Error encountered when creating the directory nil: successfully created directory
func (*ConsulStateDriver) Read ¶
func (d *ConsulStateDriver) Read(key string) ([]byte, error)
Read returns the value for a key
Parameters:
key: key for which value is to be retrieved
Return values:
[]byte: value associated with the given key
error: Error when reading from consul
nil if successful
func (*ConsulStateDriver) ReadAll ¶
func (d *ConsulStateDriver) ReadAll(baseKey string) ([][]byte, error)
ReadAll returns all state for a key
Parameters:
key: key for which all values are to be retrieved
Return values:
[][]byte: list of values associated with the given key
error: Error when writing to the KeysAPI of consul client
nil if successful
func (*ConsulStateDriver) ReadAllState ¶
func (d *ConsulStateDriver) ReadAllState(baseKey string, sType types.State, unmarshal func([]byte, interface{}) error) ([]types.State, error)
ReadAllState reads all the state for a baseKey and returns a list of types.State
Parameters:
baseKey: key whose values are to be read
sType: types.State
unmarshal: function that is used to convert key's values
from a byte slice to values of type types.State
Return values:
[]types.State: Retrieved values for a key as type types.State error: Any error returned by readAllStateCommon
func (*ConsulStateDriver) ReadState ¶
func (d *ConsulStateDriver) ReadState(key string, value types.State, unmarshal func([]byte, interface{}) error) error
ReadState reads key into a types.State using the provided unmarshaling function
Parameters:
key: key whose value is to be retrieved
value: retrieved value for the key
unmarshal: function to be used for unmarshaling retrieved
value from a byte slice in to type types.State
Return value:
error: Error returned by consul client when reading key's value
or error in unmarshaling key's value
func (*ConsulStateDriver) WatchAll ¶
func (d *ConsulStateDriver) WatchAll(baseKey string, chValueChanges chan [2][]byte) error
WatchAll watches value changes for a key in consul
Parameters:
baseKey: key for which changes are to be watched
chValueChanges: channel that will be used to communicate
any changes to values of a key
Return values:
error: Any error when watching for a value change for a key,
nil if successful
func (*ConsulStateDriver) WatchAllState ¶
func (d *ConsulStateDriver) WatchAllState(baseKey string, sType types.State, unmarshal func([]byte, interface{}) error, chStateChanges chan types.WatchState) error
WatchAllState watches all state changes for a key
Parameters:
baseKey: key to be watched sType: types.State to convert values to/from unmarshal: function used to convert values to types.State chStateChanges: channel of types.WatchState
Return values:
error: Any error when watching all state
func (*ConsulStateDriver) Write ¶
func (d *ConsulStateDriver) Write(key string, value []byte) error
Write a key-value pair to the consul KV store
Parameters:
key: key to be stored value: value to be stored
Return values:
error: Error when writing a KV pair via the consul client
nil if successful
func (*ConsulStateDriver) WriteState ¶
func (d *ConsulStateDriver) WriteState(key string, value types.State, marshal func(interface{}) ([]byte, error)) error
WriteState writes state for a key into the consul KV store
Parameters:
key: key to be stored in the KV store
value: value to be stored for the key
marshal: function to be used to convert types.State to
a byte slice
Return values:
error: Error while marshaling values for key or
when writing the key-value pair to consul,
nil if successful
type EtcdStateDriver ¶
type EtcdStateDriver struct {
// Client to access etcd
Client client.Client
// KeysAPI is used to interact with etcd's key-value
// API over HTTP
KeysAPI client.KeysAPI
}
EtcdStateDriver implements the StateDriver interface for an etcd-based distributed key-value store that is used to store any state information needed by auth proxy
func (*EtcdStateDriver) Clear ¶
func (d *EtcdStateDriver) Clear(key string) error
Clear removes a key from etcd
Parameters:
key: key to be removed
Return value:
error: Error returned by etcd client when deleting a key
func (*EtcdStateDriver) ClearState ¶
func (d *EtcdStateDriver) ClearState(key string) error
ClearState removes a key from etcd
Parameters:
key: key to be removed
Return value:
error: Error returned by etcd client when deleting a key
func (*EtcdStateDriver) Init ¶
func (d *EtcdStateDriver) Init(config *types.KVStoreConfig) error
Init initializes the state driver with needed config
Parameters:
config: configuration parameters to create etcd client
Return values:
error: error when creating an etcd client
func (*EtcdStateDriver) Mkdir ¶
func (d *EtcdStateDriver) Mkdir(key string) error
Mkdir creates a directory. If it already exists, this is a no-op.
Parameters:
key: target directory path (must begin with a slash)
Return values:
error: Error encountered when creating the directory nil: successfully created directory
func (*EtcdStateDriver) Read ¶
func (d *EtcdStateDriver) Read(key string) ([]byte, error)
Read returns state for a key
Parameters:
key: key for which value is to be retrieved
Return values:
[]byte: value associated with the given key
error: Error when writing to the KeysAPI of etcd client
nil if successful
func (*EtcdStateDriver) ReadAll ¶
func (d *EtcdStateDriver) ReadAll(baseKey string) ([][]byte, error)
ReadAll returns all values for a key
Parameters:
key: key for which all values are to be retrieved
Return values:
[][]byte: slice of values associated with the given key
error: Error when writing to the KeysAPI of etcd client
nil if successful
func (*EtcdStateDriver) ReadAllState ¶
func (d *EtcdStateDriver) ReadAllState(baseKey string, sType types.State, unmarshal func([]byte, interface{}) error) ([]types.State, error)
ReadAllState returns all state for a key
Parameters:
baseKey: key whose values are to be read
sType: types.State struct into which values are to be
unmarshaled
unmarshal: function that is used to convert key's values to
values of type types.State
Return values:
[]types.State: slice of states for the given key
error: Any error returned by readAllStateCommon
nil if successful
func (*EtcdStateDriver) ReadState ¶
func (d *EtcdStateDriver) ReadState(key string, value types.State, unmarshal func([]byte, interface{}) error) error
ReadState reads a key's value into a types.State struct using the provided unmarshaling function.
Parameters:
key: key whose value is to be retrieved
value: value of the key as types.State
unmarshal: function to be used for unmarshaling the (byte
slice) value into types.State struct
Return value:
error: Error returned by etcd client when reading key's value
or error in unmarshaling key's value
func (*EtcdStateDriver) WatchAll ¶
func (d *EtcdStateDriver) WatchAll(baseKey string, chValueChanges chan [2][]byte) error
WatchAll watches value changes for a key in etcd
Parameters:
baseKey: key for which changes are to be watched
chValueChanges: channel for communicating the changes in
the values for a key from this method
Return values:
error: Any error when watching for a state transition
for a key
nil if successful
func (*EtcdStateDriver) WatchAllState ¶
func (d *EtcdStateDriver) WatchAllState(baseKey string, sType types.State, unmarshal func([]byte, interface{}) error, chStateChanges chan types.WatchState) error
WatchAllState watches all state from the baseKey
Parameters:
baseKey: key to be watched sType: types.State struct to convert values to unmarshal: function used to convert values to types.State chStateChanges: channel of types.WatchState
Return values:
error: Any error when watching all state
func (*EtcdStateDriver) Write ¶
func (d *EtcdStateDriver) Write(key string, value []byte) error
Write state (consisting of a key-value pair) to the etcd KV store
Parameters:
key: key to be stored value: value to be stored
Return values:
error: Error when writing to the KeysAPI of etcd client
nil if successful
func (*EtcdStateDriver) WriteState ¶
func (d *EtcdStateDriver) WriteState(key string, value types.State, marshal func(interface{}) ([]byte, error)) error
WriteState writes a value of types.State for a key in the KV store
Parameters:
key: key to be stored in the KV store
value: value as types.State
marshal: function to be used to convert types.State to a form
that can be stored in the KV store
Return values:
error: Error while marshaling or writing a key-value pair
to the KV store