lock

package
v0.0.0-...-1ef5c3e Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Copyright 2021 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2021 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Copyright 2021 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	DefaultTTL          = 1000 * time.Hour // disabled to manage leftover lockfiles manually for now
	DefaultRetryBackoff = time.Minute
)

Variables

View Source
var (
	ErrLockBusy = errors.New("lock is busy")
)

Functions

This section is empty.

Types

type BucketLock

type BucketLock interface {
	// Lock tries acquiring lock or fails rigth away.
	Lock() error
	// Release tries releasing an owned lock or fails.
	Release() error
}

func NewNoop

func NewNoop() BucketLock

Noop returns a NO-OP lock, to be used when releasing stuff that won't need locking.

type InMemory

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

InMemory lock for testing puposes.

func NewInMemory

func NewInMemory() *InMemory

func (*InMemory) Lock

func (l *InMemory) Lock() error

func (*InMemory) Release

func (l *InMemory) Release() error

type Logf

type Logf func(format string, args ...interface{})

Logf logger to provide feedback on retries.

type S3

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

S3 based lock.

func NewS3

func NewS3(c S3Config, logfn Logf) (*S3, error)

NewS3 creates a lock instance ready to be used validating required AWS credentials.

func (*S3) Lock

func (l *S3) Lock() error

Lock S3 has no compare-and-swap so this is no bulletproof solution, but should be good enough.

func (*S3) Release

func (l *S3) Release() error

Release frees owned lock.

type S3Config

type S3Config struct {
	Bucket       string
	RoleARN      string
	Region       string
	Tags         string
	Filepath     string
	Owner        string
	MaxRetries   uint
	RetryBackoff time.Duration
	TTL          time.Duration
}

S3Config S3 lock config DTO.

func NewS3Config

func NewS3Config(bucketName, roleARN, awsRegion, tags, lockGroup, owner string, maxRetries uint, retryBackoff, ttl time.Duration) S3Config

Jump to

Keyboard shortcuts

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