services

package
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: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ENV_MEMCACHED_ADDRESS = os.Getenv("ENV_MEMCACHED_ADDRESS")
View Source
var ENV_REDIS_ADDRESS = os.Getenv("ENV_REDIS_ADDRESS")

Functions

This section is empty.

Types

type MemcachedService

type MemcachedService struct {
	Cache *memcache.Client
}

func NewMemcachedService

func NewMemcachedService() *MemcachedService

func (*MemcachedService) Acquire

func (ms *MemcachedService) Acquire(lock *lib.Lock) (*lib.Lock, error)
Acquire a distributed lock in Memcached

Parameters:

  • lock (*lib.Lock): // Unique lock struct

Returns:

  • *lib.Lock: // Pointer to the Lock struct
  • error: // Any errors that occured acquiring the lock

func (*MemcachedService) NewLock added in v0.0.2

func (ms *MemcachedService) NewLock(id string) *lib.Lock
NewLock: Generate a new Lock struct

Parameters:

  • id (string): // Lock Identifier MUST be unique to avoid lock collisions

Returns:

  • *lib.Lock: // Pointer to the generated Lock struct to allow for customisation.

func (*MemcachedService) Release

func (ms *MemcachedService) Release(lock *lib.Lock) (*lib.Lock, error)
Release a distributed lock in Memcached

Parameters:

  • lock (*lib.Lock): // Unique lock struct

Returns:

  • *lib.Lock: // Pointer to the Lock struct
  • error: // Any errors that occured acquiring the lock

type RedisService

type RedisService struct {
	// contains filtered or unexported fields
}
RedisService:

// A service for creating distributed locks in Redis

func NewRedisService

func NewRedisService() *RedisService
NewRedisService:

Creates a new Redis Service to allow redis locks.

Returns:

*RedisService

func (*RedisService) Acquire

func (rs *RedisService) Acquire(lock *lib.Lock) (*lib.Lock, error)
Acquire a distributed lock in Redis

Parameters:

  • lock (*lib.Lock): // Unique lock struct

Returns:

  • *lib.Lock: // Pointer to the Lock struct
  • error: // Any errors that occured acquiring the lock

func (*RedisService) NewLock added in v0.0.2

func (ms *RedisService) NewLock(id string) *lib.Lock
NewLock: Generate a new Lock struct

Parameters:

  • id (string): Lock Identifier MUST be unique to avoid lock collisions

Returns:

  • *lib.Lock: Pointer to the generated Lock struct to allow for customisation.

func (*RedisService) Release

func (rs *RedisService) Release(lock *lib.Lock) (*lib.Lock, error)
Release a distributed lock in Redis

Parameters:

  • lock (*lib.Lock): // Unique lock struct

Returns:

  • *lib.Lock: // Pointer to the Lock struct
  • error: // Any errors that occured acquiring the lock

Jump to

Keyboard shortcuts

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