-
Notifications
You must be signed in to change notification settings - Fork 0
/
aaa.go
46 lines (37 loc) · 967 Bytes
/
aaa.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
package discovery
import (
"context"
"time"
"github.com/pubgo/funk/result"
"github.com/pubgo/lava/core/service"
pbv1 "github.com/pubgo/lava/pkg/proto/lava"
// https://github.com/prometheus/prometheus/tree/main/discovery
)
type (
WatchOpt func(*WatchOpts)
GetOpt func(*GetOpts)
)
type Discovery interface {
String() string
Watch(ctx context.Context, srv string, opts ...WatchOpt) result.Result[Watcher]
GetService(ctx context.Context, srv string, opts ...GetOpt) result.Result[[]*service.Service]
}
// Watcher is an interface that returns updates
// about services within the registry.
type Watcher interface {
// Next is a blocking call
Next() result.Result[*Result]
Stop() error
}
// Result is returned by a call to Next on
// the watcher. Actions can be create, update, delete
type Result struct {
Action pbv1.EventType
Service *service.Service
}
type WatchOpts struct {
Service string
}
type GetOpts struct {
Timeout time.Duration
}