Documentation
¶
Index ¶
- Constants
- Variables
- func Dump(id uint64) (t time.Time, workerID uint64, sequence uint64)
- func SetLogLevel(str string) error
- func StdLogger() *stdlog.Logger
- func ToID(t time.Time) uint64
- func ToTime(id uint64) time.Time
- type App
- func (app *App) BytesToBinaryCmd(req bRequest) (cmd MemdCmd, err error)
- func (app *App) BytesToCmd(data []byte) (cmd MemdCmd, err error)
- func (app *App) GetStats() MemdStats
- func (app *App) HTTPGetMultiID(w http.ResponseWriter, req *http.Request)
- func (app *App) HTTPGetSingleID(w http.ResponseWriter, req *http.Request)
- func (app *App) HTTPGetStats(w http.ResponseWriter, req *http.Request)
- func (app *App) IsBinaryProtocol(r *bufio.Reader) (bool, error)
- func (app *App) ListenerSock(sockpath string) (net.Listener, error)
- func (app *App) ListenerTCP(addr string) (net.Listener, error)
- func (app *App) NextID() (uint64, error)
- func (app *App) Ready() chan interface{}
- func (app *App) RespondToBinary(r io.Reader, conn net.Conn)
- func (app *App) RunGRPCServer(ctx context.Context, cfg *Config) error
- func (app *App) RunHTTPServer(ctx context.Context, cfg *Config) error
- func (app *App) RunServer(ctx context.Context, kc *Config) error
- func (app *App) Serve(ctx context.Context, l net.Listener) error
- type Client
- type Config
- type Generator
- type HTTPClient
- type MemdBCmdGet
- type MemdBCmdStat
- type MemdBCmdVersion
- type MemdCmd
- type MemdCmdGet
- type MemdCmdQuit
- type MemdCmdStats
- type MemdCmdVersion
- type MemdStats
- type MemdValue
Constants ¶
const ( WorkerIDBits = 10 SequenceBits = 12 )
for bitshift
const (
MaxGRPCBulkSize = 1000
)
const (
MaxHTTPBulkSize = 1000
)
Variables ¶
var ( // DefaultIdleTimeout is the default idle timeout. DefaultIdleTimeout = 600 * time.Second // InfiniteIdleTimeout means that idle timeout is disabled. InfiniteIdleTimeout = time.Duration(0) )
var ( ErrInvalidWorkerID = errors.New("invalid worker id") ErrDuplicatedWorkerID = errors.New("duplicated worker") )
errors
var DefaultClientTimeout = 5 * time.Second
DefaultClientTimeout is default timeout for katsubushi client
var Epoch = time.Date(2015, 1, 1, 0, 0, 0, 0, time.UTC)
Epoch is katsubushi epoch time (2015-01-01 00:00:00 UTC) Generated ID includes elapsed time from Epoch.
var (
// Version number
Version = "development"
)
Functions ¶
func SetLogLevel ¶
SetLogLevel sets log level. Log level must be one of debug, info, warning, error, fatal and panic.
Types ¶
type App ¶
App is main struct of the Application.
func NewAppWithGenerator ¶
NewAppWithGenerator create and returns new App instance with specified Generator.
func (*App) BytesToBinaryCmd ¶
BytesToCmd converts byte array to a MemdBCmd and returns it.
func (*App) BytesToCmd ¶
BytesToCmd converts byte array to a MemdCmd and returns it.
func (*App) HTTPGetMultiID ¶
func (app *App) HTTPGetMultiID(w http.ResponseWriter, req *http.Request)
func (*App) HTTPGetSingleID ¶
func (app *App) HTTPGetSingleID(w http.ResponseWriter, req *http.Request)
func (*App) HTTPGetStats ¶
func (app *App) HTTPGetStats(w http.ResponseWriter, req *http.Request)
func (*App) IsBinaryProtocol ¶
IsBinaryProtocol judges whether a protocol is binary or text
func (*App) ListenerSock ¶
ListenerSock starts listen Unix Domain Socket on sockpath.
func (*App) ListenerTCP ¶
ListenerTCP starts listen on host:port.
func (*App) Ready ¶
func (app *App) Ready() chan interface{}
Ready returns a channel which become readable when the app can accept connections.
func (*App) RespondToBinary ¶
RespondToBinary responds to a binary request with a binary response. A request should be read from r, not conn. Because the request reader might be buffered.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is katsubushi client
func (*Client) FetchMulti ¶
FetchMulti fetches multiple ids from katsubushi
func (*Client) SetTimeout ¶
SetTimeout sets timeout to katsubushi servers
type Generator ¶
Generator is an interface to generate unique ID.
func NewGenerator ¶
NewGenerator returns new generator.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
func NewHTTPClient ¶
func NewHTTPClient(urls []string, pathPrefix string) (*HTTPClient, error)
NewHTTPClient creates HTTPClient
func (*HTTPClient) Fetch ¶
func (c *HTTPClient) Fetch(ctx context.Context) (uint64, error)
Fetch fetches id from katsubushi via HTTP
func (*HTTPClient) FetchMulti ¶
FetchMulti fetches multiple ids from katsubushi via HTTP
func (*HTTPClient) SetTimeout ¶
func (c *HTTPClient) SetTimeout(t time.Duration)
SetTimeout sets timeout to katsubushi servers
type MemdBCmdGet ¶
MemdCmdGet defines binary Get command.
type MemdBCmdStat ¶
MemdCmdStat defines binary Stat command.
func (*MemdBCmdStat) Execute ¶
func (cmd *MemdBCmdStat) Execute(app *App, w io.Writer) error
Execute writes binary stat ref. https://github.com/memcached/memcached/wiki/BinaryProtocolRevamped#stat
type MemdBCmdVersion ¶
type MemdBCmdVersion struct {
Opaque [4]byte
}
MemdBCmdVersion defines binary VERSION command.
type MemdCmdGet ¶
MemdCmdGet defines Get command.
type MemdStats ¶
type MemdStats struct { Pid int `memd:"pid" json:"pid"` Uptime int64 `memd:"uptime" json:"uptime"` Time int64 `memd:"time" json:"time"` Version string `memd:"version" json:"version"` CurrConnections int64 `memd:"curr_connections" json:"curr_connections"` TotalConnections int64 `memd:"total_connections" json:"total_connections"` CmdGet int64 `memd:"cmd_get" json:"cmd_get"` GetHits int64 `memd:"get_hits" json:"get_hits"` GetMisses int64 `memd:"get_misses" json:"get_misses"` }
MemdStats defines result of STATS command.