dilithium

package module
v0.0.0-...-2371667 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2014 License: BSD-3-Clause Imports: 17 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var DefaultServer = NewServer(nil)
View Source
var ShardTypeRegistry = NewShardRegistry()

Functions

func RegisterPoolType

func RegisterPoolType(name string, pool *Pool)

func RegisterShardType

func RegisterShardType(s Shard)

Types

type Closer

type Closer interface {
	Close()
}

type ForwardingTable

type ForwardingTable struct {
	llrb.Tree
	sync.RWMutex
}

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

type ForwardingTableEntry struct {
	MaxKey int
	Shard  Shard
}

func (*ForwardingTableEntry) Compare

func (a *ForwardingTableEntry) Compare(b llrb.Comparable) int

type PhysicalShard

type PhysicalShard struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

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.

func NewPool

func NewPool(newFn func(string) (Closer, error), maxIdle int) *Pool

NewPool returns a pool that uses newPool to create connections as needed. The pool keeps a maximum of maxIdle idle connections.

func (*Pool) Close

func (p *Pool) Close()

Close releases the resources used by the pool.

func (*Pool) Get

func (p *Pool) Get() (*pooledConnection, error)

Get gets a connection from the pool.

type Query

type Query struct {
	Method string
	Arg    QueryArg
	Reply  interface{}
	// contains filtered or unexported fields
}

func (*Query) ReadOnly

func (q *Query) ReadOnly() bool

func (*Query) Route

func (q *Query) Route() error

func (*Query) Run

func (q *Query) Run(conn interface{}) error

type QueryArg

type QueryArg interface {
	ShardKey() int
}

type ReplicateShard

type ReplicateShard struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

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) Register

func (s *Server) Register(rcvr interface{}) error

func (*Server) RegisterWithRPC

func (s *Server) RegisterWithRPC(r *rpc.Server)

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

func (*ShardRegistry) Type

func (r *ShardRegistry) Type(name string) reflect.Type

Directories

Path Synopsis
Originally from https://github.com/bitly/nsq/blob/master/nsqd/diskqueue.go (f5d970b91db18993cb986e3c5085e0048788f7fe)
Originally from https://github.com/bitly/nsq/blob/master/nsqd/diskqueue.go (f5d970b91db18993cb986e3c5085e0048788f7fe)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL