-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsoroban.go
56 lines (46 loc) · 1.58 KB
/
soroban.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
package soroban
import (
"context"
"time"
)
// Service interface
type Service interface{}
// Soroban interface
type Soroban interface {
ID() string
Register(ctx context.Context, name string, service Service) error
Start(ctx context.Context, hostname string, port int) error
StartWithTor(ctx context.Context, hostname string, port int, seed string) error
Stop(ctx context.Context)
WaitForStart(ctx context.Context)
}
type NameValue map[string]string
type StatusInfo struct {
Clients NameValue `json:"clients,omitempty"`
Cluster NameValue `json:"cluster,omitempty"`
Commandstats NameValue `json:"commandstats,omitempty"`
CPU NameValue `json:"cpu,omitempty"`
Keyspace NameValue `json:"keyspace,omitempty"`
Memory NameValue `json:"memory,omitempty"`
Persistence NameValue `json:"persistence,omitempty"`
Replication NameValue `json:"replication,omitempty"`
Server NameValue `json:"server,omitempty"`
Stats NameValue `json:"stats,omitempty"`
Raw string `json:"_raw,omitempty"`
}
// Directory interface
type Directory interface {
// Status returs internal informations
Status() (StatusInfo, error)
// TimeToLive return duration from mode.
TimeToLive(mode string) time.Duration
// List return all known values for this key.
List(key string) ([]string, error)
// Add value in key.
// TimeToLive must be greter or equals to 1 second.
// Multiple values can be store with the same key.
// TTL is the same for all values.
Add(key, value string, TTL time.Duration) error
// Remove value from key.
Remove(key, value string) error
}