forked from go-admin-team/go-admin-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
type.go
63 lines (54 loc) · 1.34 KB
/
type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package storage
import (
"context"
"time"
"github.com/bsm/redislock"
)
const (
PrefixKey = "__host"
)
type AdapterCache interface {
String() string
Get(key string) (string, error)
Set(key string, val interface{}, expire int) error
Del(key ...string) error
DelPattern(pattern string) error
HashKeys(hk string) ([]string, error)
HashGet(hk, key string) (string, error)
HashSet(hk, key string, val interface{}, expire int) error
HashDel(hk string, key ...string) error
HashDelPattern(hk, pattern string) error
Increase(key string) error
Decrease(key string) error
Expire(key string, dur time.Duration) error
GetClient() interface{}
}
type AdapterQueue interface {
String() string
Append(message Messager) error
Register(name string, f ConsumerFunc)
Run()
Shutdown()
}
type Messager interface {
SetID(string)
SetStream(string)
SetValues(map[string]interface{})
GetID() string
GetStream() string
GetValues() map[string]interface{}
GetPrefix() string
SetPrefix(string)
SetErrorCount(count int)
GetErrorCount() int
}
type ConsumerFunc func(Messager) error
type AdapterLocker interface {
String() string
Lock(key string, ttl int64, options *redislock.Options) (*redislock.Lock, error)
}
type AdapterFileStore interface {
String() string
Upload(ctx context.Context, name, location string) (string, error)
GetClient() interface{}
}