Documentation ¶
Index ¶
- Constants
- func DynamoDbUnlockMarshal(key string) map[string]*dynamodb.AttributeValue
- type GoInterval
- type LockVendor
- type Locker
- func (s *Locker) DynamoDbLock(ctx context.Context, key string, lockTtl time.Duration) (success bool, err error)
- func (s *Locker) DynamoDbUnlock(ctx context.Context, key string) error
- func (s *Locker) RedisLock(ctx context.Context, key string, lockTtl time.Duration) (success bool, err error)
- func (s *Locker) RedisUnlock(ctx context.Context, key string) error
Constants ¶
View Source
const Prefix = "GoInterLock"
Variables ¶
This section is empty.
Functions ¶
func DynamoDbUnlockMarshal ¶
func DynamoDbUnlockMarshal(key string) map[string]*dynamodb.AttributeValue
Types ¶
type GoInterval ¶
type GoInterval struct { //Name: is a unique job/task name, this is needed for distribution lock, this value enables the distribution mode. for local uses you don't need to set this value Name string // Arg: the func that need to be call in every period Arg func() // Interval: Timer Interval Interval time.Duration LockVendor LockVendor // RedisConnector : in case your app has redis connection configured already RedisConnector *redis.Client // RedisHost Redis Host the default value "localhost:6379" RedisHost string // RedisPassword: Redis Password (AUTH), It can be blank if Redis has no authentication req RedisPassword string // 0 , It's from 0 to 15 (Not for redis cluster) RedisDB string //leave empty to get from ~/.aws/credentials, (if AwsDynamoDbEndpoint not provided) AwsDynamoDbRegion string //leave empty to get from ~/.aws/credentials AwsDynamoDbEndpoint string //leave empty to get from ~/.aws/credentials, StaticCredentials (if AwsDynamoDbEndpoint not provided) AwsDynamoDbAccessKeyID string //leave empty to get from ~/.aws/credentials, StaticCredentials (if AwsDynamoDbEndpoint not provided) AwsDynamoDbSecretAccessKey string //leave empty to get from ~/.aws/credentials, StaticCredentials (if AwsDynamoDbEndpoint not provided) AwsDynamoDbSessionToken string // contains filtered or unexported fields }
func (*GoInterval) Run ¶
func (t *GoInterval) Run(ctx context.Context) error
Run to start the interval timer
func (*GoInterval) UnLock ¶
func (t *GoInterval) UnLock(ctx context.Context)
type LockVendor ¶
type LockVendor int32
const ( SingleApp LockVendor = 0 // no distributed lock RedisLock LockVendor = 1 AwsDynamoDbLock LockVendor = 2 )
type Locker ¶
type Locker struct {
// contains filtered or unexported fields
}
func (*Locker) DynamoDbLock ¶
func (*Locker) DynamoDbUnlock ¶
Click to show internal directories.
Click to hide internal directories.