Debian Codegraph @

api/v0/detector/zoo/types.go

raw symbols SCIP
1 package zoo
2
3 import (
4 "github.com/samuel/go-zookeeper/zk"
5 )
6
7 // Connector Interface to facade zk.Conn type
8 // since github.com/samuel/go-zookeeper/zk does not provide an interface
9 // for the zk.Conn object, this allows for mocking and easier testing.
10 type Connector interface {
11 Close()
12 Children(string) ([]string, *zk.Stat, error)
13 ChildrenW(string) ([]string, *zk.Stat, <-chan zk.Event, error)
14 Get(string) ([]byte, *zk.Stat, error)
15 }
16
17 //Factory is an adapter to trap the creation of zk.Conn instances
18 //since the official zk API does not expose an interface for zk.Conn.
19 type Factory interface {
20 create() (Connector, <-chan zk.Event, error)
21 }
22
23 type asFactory func() (Connector, <-chan zk.Event, error)
24
25 func (f asFactory) create() (Connector, <-chan zk.Event, error) {
26 return f()
27 }