zetcd: go.etcd.io/zetcd Index | Files

package zetcd

import "go.etcd.io/zetcd"

Index

Package Files

auth.go authconn.go bufpool.go client.go conn.go constants.go encode.go op.go path.go pool.go server.go session.go stat.go structs.go watches.go zk.go zketcd.go zketcd_path.go zklog.go

Constants

const (
    FlagEphemeral = 1
    FlagSequence  = 2
)
const (
    StateUnknown           = State(-1)
    StateDisconnected      = State(0)
    StateConnecting        = State(1)
    StateSyncConnected     = State(3)
    StateAuthFailed        = State(4)
    StateConnectedReadOnly = State(5)
    StateSaslAuthenticated = State(6)
    StateExpired           = State(-112)

    StateConnected  = State(100)
    StateHasSession = State(101)
)
const (
    DefaultPort = 2181
)

Variables

var (
    ErrConnectionClosed        = errors.New("zk: connection closed")
    ErrUnknown                 = errors.New("zk: unknown error")
    ErrAPIError                = errors.New("zk: api error")
    ErrNoNode                  = errors.New("zk: node does not exist")
    ErrNoAuth                  = errors.New("zk: not authenticated")
    ErrBadVersion              = errors.New("zk: version conflict")
    ErrNoChildrenForEphemerals = errors.New("zk: ephemeral nodes may not have children")
    ErrNodeExists              = errors.New("zk: node already exists")
    ErrNotEmpty                = errors.New("zk: node has children")
    ErrSessionExpired          = errors.New("zk: session has been expired by the server")
    ErrInvalidACL              = errors.New("zk: invalid ACL specified")
    ErrAuthFailed              = errors.New("zk: client authentication failed")
    ErrClosing                 = errors.New("zk: zookeeper is closing")
    ErrNothing                 = errors.New("zk: no server responsees to process")
    ErrSessionMoved            = errors.New("zk: session moved to another server, so operation is ignored")

    ErrBadArguments = errors.New("zk: bad arguments")
)
var (
    ErrShortBuffer        = errors.New("short buffer")
    ErrPtrExpected        = errors.New("ptr expected")
    ErrUnhandledFieldType = errors.New("unhandled field type")
)
var PerfectZXidMode bool = true

PerfectZXid is enabled to insert err writes to match zookeeper's zxids

func ReadPacket Uses

func ReadPacket(zk net.Conn, r interface{}) (string, error)

func Serve Uses

func Serve(ctx context.Context, ln net.Listener, auth AuthFunc, zk ZKFunc)

Serve will serve multiple sessions in concurrently.

func ServeSerial Uses

func ServeSerial(ctx context.Context, ln net.Listener, auth AuthFunc, zk ZKFunc)

ServeSerial has at most one inflight request at a time so two servers can be reliably cross checked.

func WritePacket Uses

func WritePacket(zk net.Conn, r interface{}) error

type ACL Uses

type ACL struct {
    Perms  int32
    Scheme string
    ID     string
}

type AuthConn Uses

type AuthConn interface {
    Read() (*AuthRequest, error)
    Write(AuthResponse) (Conn, error)
    Close()
}

AuthConn transfers zookeeper handshaking for establishing a session

func NewAuthConn Uses

func NewAuthConn(c net.Conn) AuthConn

type AuthFunc Uses

type AuthFunc func(AuthConn) (Session, error)

func NewAuth Uses

func NewAuth(c *etcd.Client) AuthFunc

type AuthRequest Uses

type AuthRequest struct {
    Req            *ConnectRequest
    FourLetterWord string
}

type AuthResponse Uses

type AuthResponse struct {
    Resp           *ConnectResponse
    FourLetterWord string
}

type CheckVersionRequest Uses

type CheckVersionRequest pathVersionRequest

type Client Uses

type Client interface {
    Send(xid Xid, req interface{}) error
    Read() <-chan ZKResponse
    StopNotify() <-chan struct{}
    Close()
}

func NewClient Uses

func NewClient(ctx context.Context, zk net.Conn) Client

type CloseRequest Uses

type CloseRequest struct{}

type CloseResponse Uses

type CloseResponse struct{}

type Conn Uses

type Conn interface {
    Send(xid Xid, zxid ZXid, resp interface{}) error
    Read() <-chan ZKRequest
    StopNotify() <-chan struct{}
    Close()
}

func NewConn Uses

func NewConn(zk net.Conn) Conn

type ConnectRequest Uses

type ConnectRequest struct {
    ProtocolVersion int32
    LastZxidSeen    ZXid
    TimeOut         int32
    SessionID       Sid
    Passwd          []byte
}

type ConnectResponse Uses

type ConnectResponse struct {
    ProtocolVersion int32
    TimeOut         int32
    SessionID       Sid
    Passwd          []byte
}

type CreateRequest Uses

type CreateRequest struct {
    Path  string
    Data  []byte
    Acl   []ACL
    Flags int32
}

type CreateResponse Uses

type CreateResponse pathResponse

type DeleteRequest Uses

type DeleteRequest pathVersionRequest

type DeleteResponse Uses

type DeleteResponse struct{}

type ErrCode Uses

type ErrCode int32

type EventType Uses

type EventType int32
const (
    EventNodeCreated EventType = iota + 1
    EventNodeDeleted
    EventNodeDataChanged
    EventNodeChildrenChanged

    EventSession     = EventType(-1)
    EventNotWatching = EventType(-2)
)

type ExistsRequest Uses

type ExistsRequest pathWatchRequest

type ExistsResponse Uses

type ExistsResponse statResponse

type GetAclRequest Uses

type GetAclRequest pathRequest

type GetAclResponse Uses

type GetAclResponse struct {
    Acl  []ACL
    Stat Stat
}

type GetChildren2Request Uses

type GetChildren2Request pathWatchRequest

type GetChildren2Response Uses

type GetChildren2Response struct {
    Children []string
    Stat     Stat
}

type GetChildrenRequest Uses

type GetChildrenRequest pathWatchRequest

type GetChildrenResponse Uses

type GetChildrenResponse struct {
    Children []string
}

type GetDataRequest Uses

type GetDataRequest pathWatchRequest

type GetDataResponse Uses

type GetDataResponse struct {
    Data []byte
    Stat Stat
}

type MultiHeader Uses

type MultiHeader struct {
    Type Op
    Done bool
    Err  ErrCode
}

type MultiRequest Uses

type MultiRequest struct {
    Ops        []MultiRequestOp
    DoneHeader MultiHeader
}

func (*MultiRequest) Decode Uses

func (r *MultiRequest) Decode(buf []byte) (int, error)

func (*MultiRequest) Encode Uses

func (r *MultiRequest) Encode(buf []byte) (int, error)

type MultiRequestOp Uses

type MultiRequestOp struct {
    Header MultiHeader
    Op     interface{}
}

type MultiResponse Uses

type MultiResponse struct {
    Ops        []MultiResponseOp
    DoneHeader MultiHeader
}

func (*MultiResponse) Decode Uses

func (r *MultiResponse) Decode(buf []byte) (int, error)

func (*MultiResponse) Encode Uses

func (r *MultiResponse) Encode(buf []byte) (int, error)

type MultiResponseOp Uses

type MultiResponseOp struct {
    Header MultiHeader
    String string
    Stat   *Stat
}

type Op Uses

type Op int32

type PingRequest Uses

type PingRequest struct{}

type PingResponse Uses

type PingResponse struct{}

type ResponseHeader Uses

type ResponseHeader struct {
    Xid  Xid
    Zxid ZXid
    Err  ErrCode
}

type Session Uses

type Session interface {
    Conn
    Watches
    Sid() Sid
    ZXid() ZXid
    ConnReq() ConnectRequest
    Backing() interface{}
}

type SessionPool Uses

type SessionPool struct {
    // contains filtered or unexported fields
}

func NewSessionPool Uses

func NewSessionPool(client *etcd.Client) *SessionPool

func (*SessionPool) Auth Uses

func (sp *SessionPool) Auth(zka AuthConn) (Session, error)

type SetAclRequest Uses

type SetAclRequest struct {
    Path    string
    Acl     []ACL
    Version Ver
}

type SetAclResponse Uses

type SetAclResponse statResponse

type SetAuthRequest Uses

type SetAuthRequest auth

type SetAuthResponse Uses

type SetAuthResponse struct{}

type SetDataRequest Uses

type SetDataRequest struct {
    Path    string
    Data    []byte
    Version Ver
}

type SetDataResponse Uses

type SetDataResponse statResponse

type SetWatchesRequest Uses

type SetWatchesRequest struct {
    RelativeZxid ZXid
    DataWatches  []string
    ExistWatches []string
    ChildWatches []string
}

type SetWatchesResponse Uses

type SetWatchesResponse struct{}

type Sid Uses

type Sid int64

type Stat Uses

type Stat struct {
    // Czxid is the zxid change that caused this znode to be created.
    Czxid ZXid
    // Mzxid is The zxid change that last modified this znode.
    Mzxid ZXid
    // Ctime is milliseconds from epoch when this znode was created.
    Ctime int64
    // Mtime is The time in milliseconds from epoch when this znode was last modified.
    Mtime          int64
    Version        Ver   // The number of changes to the data of this znode.
    Cversion       Ver   // The number of changes to the children of this znode.
    Aversion       Ver   // The number of changes to the ACL of this znode.
    EphemeralOwner Sid   // The session id of the owner of this znode if the znode is an ephemeral node. If it is not an ephemeral node, it will be zero.
    DataLength     int32 // The length of the data field of this znode.
    NumChildren    int32 // The number of children of this znode.
    Pzxid          ZXid  // last modified children
}

type State Uses

type State int32

type SyncRequest Uses

type SyncRequest pathRequest

type SyncResponse Uses

type SyncResponse pathResponse

type Ver Uses

type Ver int32 // version

type WatchHandler Uses

type WatchHandler func(ZXid, EventType)

type WatcherEvent Uses

type WatcherEvent struct {
    Type  EventType
    State State
    Path  string
}

type Watches Uses

type Watches interface {
    // Watch creates a watch request on a given path and evtype.
    Watch(rev ZXid, xid Xid, path string, evtype EventType, cb WatchHandler)

    // Wait blocks until all watches that rely on the given rev are dispatched.
    Wait(rev ZXid, path string, evtype EventType)
}

type Xid Uses

type Xid int32

type ZK Uses

type ZK interface {
    Create(xid Xid, op *CreateRequest) ZKResponse
    Delete(xid Xid, op *DeleteRequest) ZKResponse
    Exists(xid Xid, op *ExistsRequest) ZKResponse
    GetData(xid Xid, op *GetDataRequest) ZKResponse
    SetData(xid Xid, op *SetDataRequest) ZKResponse
    GetAcl(xid Xid, op *GetAclRequest) ZKResponse
    SetAcl(xid Xid, op *SetAclRequest) ZKResponse
    GetChildren(xid Xid, op *GetChildrenRequest) ZKResponse
    Sync(xid Xid, op *SyncRequest) ZKResponse
    Ping(xid Xid, op *PingRequest) ZKResponse
    GetChildren2(xid Xid, op *GetChildren2Request) ZKResponse
    // opCheck		= 13
    Multi(xid Xid, op *MultiRequest) ZKResponse
    Close(xid Xid, op *CloseRequest) ZKResponse
    SetAuth(xid Xid, op *SetAuthRequest) ZKResponse
    SetWatches(xid Xid, op *SetWatchesRequest) ZKResponse
}

ZK is a synchronous interface

func NewZKEtcd Uses

func NewZKEtcd(c *etcd.Client, s Session) ZK

func NewZKLog Uses

func NewZKLog(zk ZK) ZK

type ZKFunc Uses

type ZKFunc func(Session) (ZK, error)

func NewZK Uses

func NewZK(c *etcd.Client) ZKFunc

type ZKRequest Uses

type ZKRequest struct {
    // contains filtered or unexported fields
}

func (*ZKRequest) String Uses

func (zk *ZKRequest) String() string

type ZKResponse Uses

type ZKResponse struct {
    Hdr  *ResponseHeader
    Resp interface{}

    // Err is from transmission errors, etc
    Err error
}

func DispatchZK Uses

func DispatchZK(zk ZK, xid Xid, op interface{}) ZKResponse

type ZXid Uses

type ZXid int64

Package zetcd imports 19 packages (graph). Updated 2018-09-13. Refresh now. Tools for package owners.