Documentation ¶
Overview ¶
Derived from the Go net/rpc standard library. Copyright 2009 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Index ¶
- Variables
- func RegisterPoolType(name string, pool *Pool)
- func RegisterShardType(s Shard)
- type Closer
- type ForwardingTable
- type ForwardingTableEntry
- type PhysicalShard
- func (p *PhysicalShard) AddChild(s Shard)
- func (p *PhysicalShard) Children() []Shard
- func (p *PhysicalShard) Config() map[string]interface{}
- func (p *PhysicalShard) Destroy()
- func (p *PhysicalShard) ID() string
- func (p *PhysicalShard) Parent() Shard
- func (p *PhysicalShard) Query(q *Query) error
- func (p *PhysicalShard) RemoveChild(id string)
- func (p *PhysicalShard) SetParent(s Shard)
- func (p *PhysicalShard) Setup(config map[string]interface{}) error
- type Pool
- type Query
- type QueryArg
- type ReplicateShard
- func (r *ReplicateShard) AddChild(s Shard)
- func (r *ReplicateShard) Children() []Shard
- func (r *ReplicateShard) Config() map[string]interface{}
- func (r *ReplicateShard) Destroy()
- func (r *ReplicateShard) ID() string
- func (r *ReplicateShard) Parent() Shard
- func (r *ReplicateShard) Query(q *Query) (err error)
- func (r *ReplicateShard) RemoveChild(id string)
- func (r *ReplicateShard) SetParent(s Shard)
- func (r *ReplicateShard) Setup(config map[string]interface{}) error
- type Server
- type Shard
- type ShardConfig
- type ShardRegistry
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultServer = NewServer(nil)
View Source
var ShardTypeRegistry = NewShardRegistry()
Functions ¶
func RegisterPoolType ¶
func RegisterShardType ¶
func RegisterShardType(s Shard)
Types ¶
type ForwardingTable ¶
func NewForwardingTable ¶
func NewForwardingTable(config map[string]ShardConfig) (*ForwardingTable, error)
func NewForwardingTableFromJSON ¶
func NewForwardingTableFromJSON(r io.Reader) (*ForwardingTable, error)
func (*ForwardingTable) Delete ¶
func (t *ForwardingTable) Delete(maxKey int)
func (*ForwardingTable) Entries ¶
func (t *ForwardingTable) Entries() []*ForwardingTableEntry
func (*ForwardingTable) Insert ¶
func (t *ForwardingTable) Insert(e *ForwardingTableEntry)
func (*ForwardingTable) Lookup ¶
func (t *ForwardingTable) Lookup(key int) Shard
type ForwardingTableEntry ¶
func (*ForwardingTableEntry) Compare ¶
func (a *ForwardingTableEntry) Compare(b llrb.Comparable) int
type PhysicalShard ¶
func (*PhysicalShard) AddChild ¶
func (p *PhysicalShard) AddChild(s Shard)
func (*PhysicalShard) Children ¶
func (p *PhysicalShard) Children() []Shard
func (*PhysicalShard) Config ¶
func (p *PhysicalShard) Config() map[string]interface{}
func (*PhysicalShard) Destroy ¶
func (p *PhysicalShard) Destroy()
func (*PhysicalShard) ID ¶
func (p *PhysicalShard) ID() string
func (*PhysicalShard) Parent ¶
func (p *PhysicalShard) Parent() Shard
func (*PhysicalShard) Query ¶
func (p *PhysicalShard) Query(q *Query) error
func (*PhysicalShard) RemoveChild ¶
func (p *PhysicalShard) RemoveChild(id string)
func (*PhysicalShard) SetParent ¶
func (p *PhysicalShard) SetParent(s Shard)
func (*PhysicalShard) Setup ¶
func (p *PhysicalShard) Setup(config map[string]interface{}) error
type Pool ¶
type Pool struct { // Dial is an application supplied function for creating new connections. Dial func(url string) (Closer, error) // TestOnBorrow is an optional application supplied function for checking // the health of an idle connection before the connection is used again by // the application. Argument t is the time that the connection was returned // to the pool. If the function returns an error, then the connection is // closed. TestOnBorrow func(c Closer, t time.Time) error // Maximum number of idle connections in the pool. MaxIdle int // Close connections after remaining idle for this duration. If the value // is zero, then idle connections are not closed. Applications should set // the timeout to a value less than the server's timeout. IdleTimeout time.Duration // contains filtered or unexported fields }
Pool maintains a pool of connections. The application calls the Get method to get a connection from the pool and the connection's Close method to return the connection's resources to the pool.
type Query ¶
type ReplicateShard ¶
func (*ReplicateShard) AddChild ¶
func (r *ReplicateShard) AddChild(s Shard)
func (*ReplicateShard) Children ¶
func (r *ReplicateShard) Children() []Shard
func (*ReplicateShard) Config ¶
func (r *ReplicateShard) Config() map[string]interface{}
func (*ReplicateShard) Destroy ¶
func (r *ReplicateShard) Destroy()
func (*ReplicateShard) ID ¶
func (r *ReplicateShard) ID() string
func (*ReplicateShard) Parent ¶
func (r *ReplicateShard) Parent() Shard
func (*ReplicateShard) Query ¶
func (r *ReplicateShard) Query(q *Query) (err error)
func (*ReplicateShard) RemoveChild ¶
func (r *ReplicateShard) RemoveChild(id string)
func (*ReplicateShard) SetParent ¶
func (r *ReplicateShard) SetParent(s Shard)
func (*ReplicateShard) Setup ¶
func (r *ReplicateShard) Setup(config map[string]interface{}) error
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(forwarding *ForwardingTable) *Server
func (*Server) RegisterWithRPC ¶
type Shard ¶
type Shard interface { // Get the parent of the shard. nil if the Shard is the root. Parent() Shard Children() []Shard SetParent(s Shard) AddChild(s Shard) // RemoveChild removes the child shard with ID() == id. // The receiver is responsible for calling Destroy() on the child shard. RemoveChild(id string) Query(q *Query) error // ID returns the shard ID. It must uniquely identify the shard. ID() string // Setup is called to setup the shard with the specified config. Setup(config map[string]interface{}) error // Config returns a JSON-serializable config that could be passed to Setup to recreate this shard. Config() map[string]interface{} // Destroy is called when the shard is removed from the tree. The shard must call Destroy on child shards. Destroy() // The shard must be locked before unmarshalling the configuration into it. sync.Locker }
type ShardConfig ¶
type ShardConfig struct { Type string `json:"type"` Config map[string]interface{} `json:"config"` Children []ShardConfig `json:"children"` }
func NewShardConfig ¶
func NewShardConfig(s Shard) (*ShardConfig, error)
func (*ShardConfig) NewShard ¶
func (config *ShardConfig) NewShard() (shard Shard, err error)
type ShardRegistry ¶
type ShardRegistry struct {
// contains filtered or unexported fields
}
func NewShardRegistry ¶
func NewShardRegistry() *ShardRegistry
func (*ShardRegistry) Add ¶
func (r *ShardRegistry) Add(s Shard)
func (*ShardRegistry) Name ¶
func (r *ShardRegistry) Name(s Shard) string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.