lock

package
v0.0.0-...-7d5e071 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2017 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultLockService

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

DefaultLockService queries the k8s master to find out if a pod is building a project+branch.

func (*DefaultLockService) Acquire

func (t *DefaultLockService) Acquire(obj v1.UserBuildEvent) error

Acquire attempts to acquire a lock on the given object

func (*DefaultLockService) Release

func (t *DefaultLockService) Release(obj v1.UserBuildEvent) error

Release is a no op for the default lock service.

type DynamoDB

type DynamoDB interface {
	PutItem(*dynamodb.PutItemInput) (*dynamodb.PutItemOutput, error)
	DeleteItem(*dynamodb.DeleteItemInput) (*dynamodb.DeleteItemOutput, error)
}

DynamoDB is a minimal DynamoDB interface

func NewDynamoDB

func NewDynamoDB(awsAccessKey, awsAccessSecret, awsRegion string) DynamoDB

NewDynamoDB returns a new DynamoDB instance initialized with the give access key, secret,and region.

type DynamoDbLockService

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

DynamoDbLockService implements a distributed lock service on top of Amazon DynamoDB.

func (DynamoDbLockService) Acquire

func (l DynamoDbLockService) Acquire(lock v1.UserBuildEvent) error

Acquire conditionally puts a lock representation in DynamoDb for the given input lock. The operation will fail if the lock exists and is not expired. A locked is deemed good (unexpired) for a finite amount of time, should a process for some reason fail to remove it manually after a branch build is completed.

func (DynamoDbLockService) Release

func (l DynamoDbLockService) Release(lock v1.UserBuildEvent) error

Release removes a lock from the lock table.

type LockService

type LockService interface {
	Acquire(v1.UserBuildEvent) error
	Release(v1.UserBuildEvent) error
}

LockService defines the exported interface that a distributed lock service supports.

func NewDefault

func NewDefault(clientset k8s2.PodsGetter) LockService

NewDefault defines a lock service with an Acquqire method that simply queries k8s master for whether a build is running with the input v1.UserBuildEvent's lockname.

func NewDynamoDbLockService

func NewDynamoDbLockService(db DynamoDB) LockService

NewDynamoDbLockService creates a new distributed lock service on top of DynamoDb.

Jump to

Keyboard shortcuts

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