distributedlocker

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

README

Distributed Locker

Simple Distributed Lock Library written in Golang.

Example usage:

package main

import (
	"log"
	"time"

	dl "gitlab.com/bf86/lib/go/distributedlocker"
	"gitlab.com/bf86/lib/go/distributedlocker/services"
)

func main() {
	client := services.NewMemcachedService()
	locker := dl.NewLocker(client)
	lock := locker.NewLock()

	err := locker.Acquire(lock)
	if err != nil {
		log.Fatalf("Lock Failed: %s", err.Error())
	}

	defer locker.Release(lock)

	// Run your distrubte locked code!
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Locker

type Locker struct {
	LockService interfaces.LockService
}

func NewLocker

func NewLocker(client interfaces.LockService) *Locker

func (*Locker) Acquire

func (dl *Locker) Acquire(lock *lib.Lock) error

func (*Locker) NewLock added in v0.0.2

func (dl *Locker) NewLock() *lib.Lock

func (*Locker) Release

func (dl *Locker) Release(lock *lib.Lock)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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