-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
73 lines (54 loc) · 1.72 KB
/
types.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
64
65
66
67
68
69
70
71
72
73
package bank
import (
"context"
"time"
"git.condensat.tech/bank/database/model"
logModel "git.condensat.tech/bank/logger/model"
"code.condensat.tech/bank/secureid"
)
type BankObject interface {
Encode() ([]byte, error)
Decode(data []byte) error
}
type ServerOptions struct {
Protocol string
HostName string
Port int
}
type Logger interface {
Close()
CreateLogEntry(timestamp time.Time, app, level string, userID uint64, sessionID string, method, err, msg, data string) *logModel.LogEntry
AddLogEntries(entries []*logModel.LogEntry) error
}
// Messaging (Nats)
type NC interface{}
type MessageHandler func(ctx context.Context, subject string, message *Message) (*Message, error)
type Messaging interface {
NC() NC
SubscribeWorkers(ctx context.Context, subject string, workerCount int, handle MessageHandler)
Subscribe(ctx context.Context, subject string, handle MessageHandler)
Publish(ctx context.Context, subject string, message *Message) error
Request(ctx context.Context, subject string, message *Message) (*Message, error)
RequestWithTimeout(ctx context.Context, subject string, message *Message, timeout time.Duration) (*Message, error)
}
// Database (GORM)
type DB interface{}
type Database interface {
DB() DB
Migrate(models []model.Model) error
Transaction(txFunc func(tx Database) error) error
}
// Cache (Redis)
type RDB interface{}
type Cache interface {
RDB() RDB
}
type Worker interface {
Run(ctx context.Context, numWorkers int)
}
type SecureID interface {
ToSecureID(context string, value secureid.Value) (secureid.SecureID, error)
FromSecureID(context string, secureID secureid.SecureID) (secureid.Value, error)
ToString(secureID secureid.SecureID) string
Parse(secureID string) secureid.SecureID
}