Skip to content

Commit

Permalink
fix some typos and add some comments to constants.go
Browse files Browse the repository at this point in the history
  • Loading branch information
linsite authored and nemith committed Sep 28, 2021
1 parent 8866d76 commit a930334
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
12 changes: 6 additions & 6 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
var ErrNoServer = errors.New("zk: could not connect to a server")

// ErrInvalidPath indicates that an operation was being attempted on
// an invalid path. (e.g. empty path)
// an invalid path. (e.g. empty path).
var ErrInvalidPath = errors.New("zk: invalid path")

// DefaultLogger uses the stdlib log package for logging.
Expand Down Expand Up @@ -243,15 +243,15 @@ func WithHostProvider(hostProvider HostProvider) connOption {
}
}

// WithLogger returns a connection option specifying a non-default Logger
// WithLogger returns a connection option specifying a non-default Logger.
func WithLogger(logger Logger) connOption {
return func(c *Conn) {
c.logger = logger
}
}

// WithLogInfo returns a connection option specifying whether or not information messages
// shoud be logged.
// should be logged.
func WithLogInfo(logInfo bool) connOption {
return func(c *Conn) {
c.logInfo = logInfo
Expand Down Expand Up @@ -301,7 +301,7 @@ func WithMaxBufferSize(maxBufferSize int) connOption {
}

// WithMaxConnBufferSize sets maximum buffer size used to send and encode
// packets to Zookeeper server. The standard Zookeepeer client for java defaults
// packets to Zookeeper server. The standard Zookeeper client for java defaults
// to a limit of 1mb. This option should be used for non-standard server setup
// where znode is bigger than default 1mb.
func WithMaxConnBufferSize(maxBufferSize int) connOption {
Expand Down Expand Up @@ -947,7 +947,7 @@ func (c *Conn) AddAuth(scheme string, auth []byte) error {
// Remember authdata so that it can be re-submitted on reconnect
//
// FIXME(prozlach): For now we treat "userfoo:passbar" and "userfoo:passbar2"
// as two different entries, which will be re-submitted on reconnet. Some
// as two different entries, which will be re-submitted on reconnect. Some
// research is needed on how ZK treats these cases and
// then maybe switch to something like "map[username] = password" to allow
// only single password for given user with users being unique.
Expand Down Expand Up @@ -1376,7 +1376,7 @@ func resendZkAuth(ctx context.Context, c *Conn) error {
return ctx.Err()
}
if res.err != nil {
return fmt.Errorf("failed conneciton setAuth request: %v", res.err)
return fmt.Errorf("failed connection setAuth request: %v", res.err)
}
}

Expand Down
14 changes: 12 additions & 2 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

const (
protocolVersion = 0

// DefaultPort is the default port listened by server.
DefaultPort = 2181
)

Expand Down Expand Up @@ -38,11 +38,13 @@ const (
)

const (
// EventNodeCreated represents a node is created.
EventNodeCreated EventType = 1
EventNodeDeleted EventType = 2
EventNodeDataChanged EventType = 3
EventNodeChildrenChanged EventType = 4

// EventSession represents a session event.
EventSession EventType = -1
EventNotWatching EventType = -2
)
Expand All @@ -59,6 +61,7 @@ var (
)

const (
// StateUnknown means the session state is unknown.
StateUnknown State = -1
StateDisconnected State = 0
StateConnecting State = 1
Expand All @@ -72,6 +75,7 @@ const (
)

const (
// FlagEphemeral means the node is ephemeral.
FlagEphemeral = 1
FlagSequence = 2
FlagTTL = 4
Expand All @@ -91,18 +95,22 @@ var (
}
)

// State is the session state.
type State int32

// String converts State to a readable string.
func (s State) String() string {
if name := stateNames[s]; name != "" {
return name
}
return "Unknown"
}

// ErrCode is the error code defined by server. Refer to ZK documentations for more specifics.
type ErrCode int32

var (
// ErrConnectionClosed means the connection has been closed.
ErrConnectionClosed = errors.New("zk: connection closed")
ErrUnknown = errors.New("zk: unknown error")
ErrAPIError = errors.New("zk: api error")
Expand All @@ -117,7 +125,7 @@ var (
ErrInvalidFlags = errors.New("zk: invalid flags specified")
ErrAuthFailed = errors.New("zk: client authentication failed")
ErrClosing = errors.New("zk: zookeeper is closing")
ErrNothing = errors.New("zk: no server responsees to process")
ErrNothing = errors.New("zk: no server responses to process")
ErrSessionMoved = errors.New("zk: session moved to another server, so operation is ignored")
ErrReconfigDisabled = errors.New("attempts to perform a reconfiguration operation when reconfiguration feature is disabled")
ErrBadArguments = errors.New("invalid arguments")
Expand Down Expand Up @@ -184,6 +192,7 @@ const (

// Constants for ACL permissions
const (
// PermRead represents the permission needed to read a znode.
PermRead = 1 << iota
PermWrite
PermCreate
Expand Down Expand Up @@ -220,6 +229,7 @@ var (
}
)

// EventType represents the event type sent by server.
type EventType int32

func (t EventType) String() string {
Expand Down

0 comments on commit a930334

Please sign in to comment.