Documentation
¶
Index ¶
- Variables
- func Recover(e interface{}) error
- func WithContext(ctx context.Context) func(opts *Options)
- func WithDelay(delay bool) func(opts *Options)
- func WithEndpoint(endpoint string) func(opts *Options)
- func WithLeaseDuration(d time.Duration) func(opts *Options)
- func WithLogger(logger Logger) func(opts *Options)
- func WithNoPanic() func(opts *Options)
- func WithRegion(region string) func(opts *Options)
- type DynamoDBLocker
- type Logger
- type Options
Constants ¶
This section is empty.
Variables ¶
var (
DefaultLeaseDuration = 10 * time.Second
)
Default values
Functions ¶
func WithContext ¶ added in v0.1.0
WithContext specifies the Context used by Lock() and Unlock().
func WithDelay ¶
WithDelay will delay the acquisition of the lock if it fails to acquire the lock. This is similar to the N option of setlock. The default is delay enalbed(true). Specify false if you want to exit immediately if Lock acquisition fails.
func WithEndpoint ¶
WithEndpoint is an endpoint specification option for Local development. Please enter the URL of DynamoDB Local etc.
func WithLeaseDuration ¶
WithLeaseDuration affects the heartbeat interval and TTL after Lock acquisition. The default is 10 seconds
func WithLogger ¶
WithLogger is a setting to enable the log output of DynamoDB Locker. By default, Logger that does not output anywhere is specified.
func WithNoPanic ¶
func WithNoPanic() func(opts *Options)
WithNoPanic changes the behavior so that it does not panic if an error occurs in the Lock () and Unlock () functions. Check the LastErr () function to see if an error has occurred when WithNoPanic is specified.
func WithRegion ¶
WithRegion specifies the AWS Region. Default AWS_DEFAULT_REGION env
Types ¶
type DynamoDBLocker ¶
type DynamoDBLocker struct {
// contains filtered or unexported fields
}
DynamoDB Locker implements the sync.Locker interface and provides a Lock mechanism using DynamoDB.
func New ¶
func New(urlStr string, optFns ...func(*Options)) (*DynamoDBLocker, error)
New returns *DynamoDBLocker
func (*DynamoDBLocker) ClearLastErr ¶ added in v0.3.0
func (l *DynamoDBLocker) ClearLastErr()
func (*DynamoDBLocker) LastErr ¶ added in v0.3.0
func (l *DynamoDBLocker) LastErr() error
func (*DynamoDBLocker) LockWithErr ¶
func (l *DynamoDBLocker) LockWithErr(ctx context.Context) (bool, error)
LockWithErr try get lock. The return value of bool indicates whether Lock has been released. If true, it is Lock Granted.
func (*DynamoDBLocker) UnlockWithErr ¶
func (l *DynamoDBLocker) UnlockWithErr(ctx context.Context) error
UnlockWithErr unlocks. Delete DynamoDB items
type Logger ¶
type Logger interface { Print(v ...interface{}) Printf(format string, v ...interface{}) Println(v ...interface{}) }
Logger is a Logging interface used inside DynamoDB Locker
type Options ¶
type Options struct { NoPanic bool Logger Logger Delay bool Endpoint string Region string LeaseDuration time.Duration // contains filtered or unexported fields }
Options are for changing the behavior of DynamoDB Locker and are changed by the function passed to the New () function. See the WithXXX options for more information.