Documentation ¶
Index ¶
- Constants
- func GetAgentName(cc *api.Client) (string, error)
- func GetKV() *api.KV
- func GetSession(cc *api.Client, serviceKey, agentName string) (string, error)
- func InitConsulPublisher(maxItems int, kv *api.KV)
- func IsAnyLeader(cc *api.Client, serviceKey string, waitIndex uint64) (bool, string, uint64, error)
- func RegisterServerAsConsulService(cfg config.Configuration, cc *api.Client, chShutdown chan struct{}) error
- func StoreConsulKey(key string, value []byte) error
- func StoreConsulKeyAsString(key, value string) error
- func StoreConsulKeyAsStringWithFlags(key, value string, flags uint64) error
- func StoreConsulKeyWithFlags(key string, value []byte, flags uint64) error
- func UnregisterServerAsConsulService(cfg config.Configuration, cc *api.Client)
- func WatchLeaderElection(cc *api.Client, serviceKey string, chStop chan struct{}, ...)
- type AutoDeleteLock
- type ConsulStore
Constants ¶
const ConsulGenericErrMsg = "Consul communication error"
ConsulGenericErrMsg is a generic error message used when wrapping Consul errors
const DeploymentKVPrefix string = yorcPrefix + "/deployments"
DeploymentKVPrefix is the prefix in Consul KV store for deployments
const EventsPrefix = yorcPrefix + "/events"
EventsPrefix is the prefix in Consul KV store for events concerning all the deployments
const ExecutionsTaskPrefix = yorcPrefix + "/executions"
ExecutionsTaskPrefix is the prefix in Consul KV store for execution task
const HostsPoolPrefix = yorcPrefix + "/hosts_pool"
HostsPoolPrefix is the prefix on KV store for the hosts pool service
const LogsPrefix = yorcPrefix + "/logs"
LogsPrefix is the prefix on KV store for logs concerning all the deployments
const MonitoringKVPrefix string = yorcPrefix + "/monitoring"
MonitoringKVPrefix is the prefix in Consul KV store for monitoring
const SchedulingKVPrefix string = yorcPrefix + "/scheduling"
SchedulingKVPrefix is the prefix in Consul KV store for scheduling
const TasksPrefix = yorcPrefix + "/tasks"
TasksPrefix is the prefix in Consul KV store for tasks
const WorkflowsPrefix = yorcPrefix + "/workflows"
WorkflowsPrefix is the prefix in Consul KV store for workflows runtime data
const YorcManagementPrefix = yorcPrefix + "/.yorc_management"
YorcManagementPrefix is the prefix on KV store for the orchestrator own management
const YorcSchemaVersion = "1.0.0"
YorcSchemaVersion is the version of the data schema in Consul understood by this version of Yorc
const YorcSchemaVersionPath = yorcPrefix + "/database_schema_version"
YorcSchemaVersionPath is the path where the data schema version is stored in Consul
const YorcService = "yorc"
YorcService is the service name for yorc as a Consul service
const YorcServicePrefix = yorcPrefix + "/service"
YorcServicePrefix is the prefix used for storing services keys
Variables ¶
This section is empty.
Functions ¶
func GetAgentName ¶
GetAgentName allows to return the local consul agent name
func GetSession ¶
GetSession allows to return the session ID for a defined service leader key
func InitConsulPublisher ¶
InitConsulPublisher starts a Consul Publisher and limit the number of parallel call to the Consul API to store keys with the given maxItems.
It is safe but discouraged to call several times this function. Only the last call will be taken into account. The only valid reason to do so is for reconfiguration and changing the limit.
func IsAnyLeader ¶
IsAnyLeader allows to return true if any leader exists for a defined service key
func RegisterServerAsConsulService ¶
func RegisterServerAsConsulService(cfg config.Configuration, cc *api.Client, chShutdown chan struct{}) error
RegisterServerAsConsulService allows to register the Yorc server as a Consul service
func StoreConsulKey ¶
StoreConsulKey is equivalent to StoreConsulKeyWithFlags(key, []byte(value),0)
func StoreConsulKeyAsString ¶
StoreConsulKeyAsString is equivalent to StoreConsulKeyWithFlags(key, []byte(value),0)
func StoreConsulKeyAsStringWithFlags ¶
StoreConsulKeyAsStringWithFlags is equivalent to StoreConsulKeyWithFlags(key, []byte(value),flags)
func StoreConsulKeyWithFlags ¶
StoreConsulKeyWithFlags stores a Consul key without the use of a ConsulStore you should avoid to use it when storing several keys that could be stored concurrently as this function has an important overhead of creating an execution context using the WithContext function and waiting for the key to be store in Consul using errGroup.Wait() The given flags mask is associated to the K/V (See Flags in api.KVPair).
func UnregisterServerAsConsulService ¶
func UnregisterServerAsConsulService(cfg config.Configuration, cc *api.Client)
UnregisterServerAsConsulService allows to unregister the Yorc server as a Consul service
func WatchLeaderElection ¶
func WatchLeaderElection(cc *api.Client, serviceKey string, chStop chan struct{}, leaderServiceStart func(), leaderServiceStop func())
WatchLeaderElection allows to watch for leader election for defined service. It elects leader if needed and can start the related service or stop it if node is no longer leader
Types ¶
type AutoDeleteLock ¶
AutoDeleteLock is a composition of an consul Lock but its Unlock function also call the Destroy function
func (*AutoDeleteLock) Unlock ¶
func (adl *AutoDeleteLock) Unlock() error
Unlock calls in sequence Unlock from the original lock then destroy
type ConsulStore ¶
type ConsulStore interface { StoreConsulKey(key string, value []byte) StoreConsulKeyWithFlags(key string, value []byte, flags uint64) StoreConsulKeyAsString(key, value string) StoreConsulKeyAsStringWithFlags(key, value string, flags uint64) }
ConsulStore allows to store keys in Consul
func WithContext ¶
WithContext uses a given context to create an errgroup.Group that will be use to store keys in Consul in parallel.
If the given context is cancelled then keys storing are not executed. If an error occurs when storing a key then the context is cancelled and others keys are not stored. The error could be retrieved with the Wait() function of the errgroup.Group.
Here is a typical use case for this function:
errCtx, errGroup, consulStore := consulutil.WithContext(ctx) consulStore.StoreConsulKey(key1, val1) // several concurrent keys storing consulStore.StoreConsulKey(keyN, valN) err := errGroup.Wait()