Documentation ¶
Overview ¶
Package client provides a generic access layer for data available in system
Index ¶
- Constants
- Variables
- func GetTableKeySeparator(target string) (string, error)
- func ValToResp(val Value) (*gnmipb.SubscribeResponse, error)
- type Client
- type DbClient
- func (c *DbClient) Close() error
- func (c *DbClient) Get(w *sync.WaitGroup) ([]*spb.Value, error)
- func (c *DbClient) PollRun(q *queue.PriorityQueue, poll chan struct{}, w *sync.WaitGroup)
- func (c *DbClient) StreamRun(q *queue.PriorityQueue, stop chan struct{}, w *sync.WaitGroup)
- func (c *DbClient) String() string
- type Node
- type NonDbClient
- func (c *NonDbClient) Close() error
- func (c *NonDbClient) Get(w *sync.WaitGroup) ([]*spb.Value, error)
- func (c *NonDbClient) PollRun(q *queue.PriorityQueue, poll chan struct{}, w *sync.WaitGroup)
- func (c *NonDbClient) StreamRun(q *queue.PriorityQueue, stop chan struct{}, w *sync.WaitGroup)
- func (c *NonDbClient) String() string
- type Stream
- type Trie
- type Value
Constants ¶
View Source
const ( Default_REDIS_UNIXSOCKET string = "/var/run/redis/redis.sock" Default_REDIS_LOCAL_TCP_PORT string = "localhost:6379" )
View Source
const ( DbIdx uint = iota // DB name is the first element (no. 0) in path slice. TblIdx // Table name is the second element (no. 1) in path slice. KeyIdx // Key name is the first element (no. 2) in path slice. FieldIdx // Field name is the first element (no. 3) in path slice. )
For virtual db path
Variables ¶
View Source
var Target2RedisDb = make(map[string]*redis.Client)
redis client connected to each DB
View Source
var UseRedisLocalTcpPort bool = false
Let it be variable visible to other packages for now. May add an interface function for it.
Functions ¶
func GetTableKeySeparator ¶
Types ¶
type Client ¶
type Client interface { // StreamRun will start watching service on data source // and enqueue data change to the priority queue. // It stops all activities upon receiving signal on stop channel // It should run as a go routine StreamRun(q *queue.PriorityQueue, stop chan struct{}, w *sync.WaitGroup) // Poll will start service to respond poll signal received on poll channel. // data read from data source will be enqueued on to the priority queue // The service will stop upon detection of poll channel closing. // It should run as a go routine PollRun(q *queue.PriorityQueue, poll chan struct{}, w *sync.WaitGroup) // Get return data from the data source in format of *spb.Value Get(w *sync.WaitGroup) ([]*spb.Value, error) // Close provides implemenation for explicit cleanup of Client Close() error }
Client defines a set of methods which every client must implement. This package provides one implmentation for now: the DbClient
type DbClient ¶
type DbClient struct {
// contains filtered or unexported fields
}
func (*DbClient) PollRun ¶
func (c *DbClient) PollRun(q *queue.PriorityQueue, poll chan struct{}, w *sync.WaitGroup)
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Trie implmentation is adpated from https://github.com/derekparker/trie/blob/master/trie.go
func (*Node) RemoveChild ¶
type NonDbClient ¶
type NonDbClient struct {
// contains filtered or unexported fields
}
func (*NonDbClient) Close ¶
func (c *NonDbClient) Close() error
TODO: Log data related to this session
func (*NonDbClient) PollRun ¶
func (c *NonDbClient) PollRun(q *queue.PriorityQueue, poll chan struct{}, w *sync.WaitGroup)
func (*NonDbClient) StreamRun ¶
func (c *NonDbClient) StreamRun(q *queue.PriorityQueue, stop chan struct{}, w *sync.WaitGroup)
To be implemented
func (*NonDbClient) String ¶
func (c *NonDbClient) String() string
String returns the target the client is querying.
type Stream ¶
type Stream interface {
Send(m *gnmipb.SubscribeResponse) error
}
Click to show internal directories.
Click to hide internal directories.