consullocker

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

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

Go to latest
Published: Sep 5, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package consullocker provides a locking mechanism using a Consul server.

Consul's (https://www.consul.io) key/value storage system can also be used for building a distributed exclusive locking mechanism, often referred to as leader election (https://www.consul.io/docs/guides/leader-election.html).

Due to Consul being an external server, connection issues can occur between tusd and Consul. In this situation, tusd cannot always ensure that it still holds a lock and may panic in an unrecoverable way. This may seems like an inconvenient decision but is probably the best solution since we are not able to interrupt other goroutines which may be involved in moving the uploaded data to a backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsulLocker

type ConsulLocker struct {
	// Client used to connect to the Consul server
	Client *consul.Client

	// ConnectionName is an optional field which may contain a human-readable
	// description for the connection. It is only used for composing error
	// messages and can be used to match them to a specific Consul instance.
	ConnectionName string
	// contains filtered or unexported fields
}

func New

func New(client *consul.Client) *ConsulLocker

New constructs a new locker using the provided client.

func (*ConsulLocker) LockUpload

func (locker *ConsulLocker) LockUpload(id string) error

LockUpload tries to obtain the exclusive lock.

func (*ConsulLocker) UnlockUpload

func (locker *ConsulLocker) UnlockUpload(id string) error

UnlockUpload releases a lock.

func (*ConsulLocker) UseIn

func (locker *ConsulLocker) UseIn(composer *tusd.StoreComposer)

UseIn adds this locker to the passed composer.

Jump to

Keyboard shortcuts

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