Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mutex ¶
type Mutex struct {
// contains filtered or unexported fields
}
Mutex is similar to sync.Mutex, except usable by multiple plugin instances across a cluster.
Internally, a mutex relies on an atomic key-value set operation as exposed by the Mattermost plugin API.
Mutexes with different names are unrelated. Mutexes with the same name from different plugins are unrelated. Pick a unique name for each mutex your plugin requires.
A Mutex must not be copied after first use.
func NewMutex ¶
func NewMutex(pluginAPI MutexPluginAPI, metricsAPI MutexMetricsAPI, key string, cfg MutexConfig) (*Mutex, error)
NewMutex creates a mutex with the given key name.
type MutexConfig ¶ added in v0.19.0
type MutexConfig struct {
// TTL is the interval after which a locked mutex will expire unless
// refreshed.
TTL time.Duration
// RefreshInterval is the interval on which the mutex will be refreshed when
// locked.
RefreshInterval time.Duration
// PollInterval is the interval to wait between locking attempts.
PollInterval time.Duration
// MetricsGroup is an optional group name to use for mutex related metrics.
MetricsGroup string
}
func (*MutexConfig) IsValid ¶ added in v0.19.0
func (c *MutexConfig) IsValid() error
func (*MutexConfig) SetDefaults ¶ added in v0.19.0
func (c *MutexConfig) SetDefaults()
type MutexMetricsAPI ¶ added in v0.19.0
type MutexMetricsAPI interface {
ObserveClusterMutexGrabTime(key string, elapsed float64)
ObserveClusterMutexLockedTime(key string, elapsed float64)
IncClusterMutexLockRetries(group string)
}
MutexMetricsAPI is an interface to manage cluster mutex metrics.
type MutexPluginAPI ¶
type MutexPluginAPI interface {
KVSetWithOptions(key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError)
KVDelete(key string) *model.AppError
LogError(msg string, keyValuePairs ...interface{})
LogWarn(msg string, keyValuePairs ...interface{})
LogDebug(msg string, keyValuePairs ...interface{})
}
MutexPluginAPI is the plugin API interface required to manage mutexes.
Click to show internal directories.
Click to hide internal directories.