Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackOffGenerator ¶
type BackOffGenerator func() backoff.BackOff
BackOffGenerator is used to create new backoff iterators.
func DefaultBackOffGenerator ¶
func DefaultBackOffGenerator() BackOffGenerator
DefaultBackOffGenerator provides a default exponential backoff implementation for use with WithBackOffGenerator.
type GCSLock ¶
type GCSLock struct {
// contains filtered or unexported fields
}
GCSLock uses the strong-consistency guarantees of Google Cloud Storage (GCS) to provide a fault-tolerant, globally-distributed lock via an HTTP API.
It does so by writing a specific object to a specified bucket on lock acquisition, retrying (with backoff) if the file already exists or when a network error occurs. To release the lock, the same object is deleted.
See https://cloud.google.com/storage/docs/consistency for more details on the consistency guarantees provided by GCS.
func NewGCSLock ¶
NewGCSLock creates a new Google Cloud Storage (GCS) globally-consistent contextlock.ContextLocker type, which will write the lock file to the provided GCS bucket and object (directory & file).
func (*GCSLock) ForceUnlockContext ¶
ForceUnlockContext is a special variant of UnlockContext that will forcefully unlock the global state by deleting the GCS object even if the local lock instance did not create it.
This method can be useful to reset the global lock state when the process that acquired the lock exits abnormally and fails to release its lock.
func (*GCSLock) LockContext ¶
LockContext implements contextlock.ContextLocker.
type HTTPClientDoer ¶
HTTPClientDoer provides an interface wrapper around a *http.Client.
func DefaultGoogleHTTPClient ¶
func DefaultGoogleHTTPClient(ctx context.Context, scopes ...string) (HTTPClientDoer, error)
DefaultGoogleHTTPClient provides a standard Google API HTTP client to be used with WitHTTPClient.
type LockFileMetadataGenerator ¶
LockFileMetadataGenerator creates output data to be stored in a GCS lock file when created. This may contain useful information about the locker's identity and execution path for debugging purposes.
func DefaultLockFileMetadataGenerator ¶
func DefaultLockFileMetadataGenerator() LockFileMetadataGenerator
DefaultLockFileMetadataGenerator provides a default lock file metadata generator including information about the time, host, and call stack of the lock acquisition call to be used with WithLockFileMetadataGenerator.
type Option ¶
type Option func(*GCSLock)
Option provides structured optional arguments to NewGCSLock.
func WitHTTPClient ¶
func WitHTTPClient(httpClient HTTPClientDoer) Option
WitHTTPClient sets the HTTP client to use with GCSLock HTTP calls to the Google Cloud Storage API.
func WithBackOffGenerator ¶
func WithBackOffGenerator(backOffGenerator BackOffGenerator) Option
WithBackOffGenerator sets the backoff implementation to use with GCSLock.
func WithBaseURL ¶
WithBaseURL sets the base URL for the Google Cloud Storage API to use with HTTP calls from GCSLock.
func WithLockFileMetadataGenerator ¶
func WithLockFileMetadataGenerator(generator LockFileMetadataGenerator) Option
WithLockFileMetadataGenerator sets the lock file metadata generator to be used with GCSLock.
func WithLogger ¶
WithLogger sets the Zap logger to use with the GCSLock.