forked from Velocidex/velociraptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrontend.go
46 lines (34 loc) · 969 Bytes
/
frontend.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 services
import (
"context"
"os"
"sync"
api_proto "www.velocidex.com/golang/velociraptor/api/proto"
)
// The frontend service manages load balancing between multiple
// frontends. Velociraptor clients may be redirected between active
// frontends to spread the load between them.
var (
frontend_mu sync.Mutex
gFrontend FrontendManager
FrontendIsMaster = os.ErrNotExist
)
func RegisterFrontendManager(frontend FrontendManager) {
frontend_mu.Lock()
defer frontend_mu.Unlock()
gFrontend = frontend
}
func GetFrontendManager() FrontendManager {
frontend_mu.Lock()
defer frontend_mu.Unlock()
return gFrontend
}
type FrontendManager interface {
IsMaster() bool
// Establish a gRPC connection to the master node. If we are
// running on the master node already then returns a
// fs.ErrNotExist error. If we fail to connect returns another
// error.
GetMasterAPIClient(ctx context.Context) (
api_proto.APIClient, func() error, error)
}