Documentation
¶
Overview ¶
@Title @Description @Author Wangwengang 2024/1/8 13:05 @Update Wangwengang 2024/1/8 13:05
@Title @Description @Author Wangwengang 2024/1/8 12:59 @Update Wangwengang 2024/1/8 12:59
@Title @Description @Author Wangwengang 2024/1/8 13:00 @Update Wangwengang 2024/1/8 13:00
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Mutex ¶
type Mutex struct {
// contains filtered or unexported fields
}
Mutex implements the sync Locker interface with etcd
func (*Mutex) Header ¶
func (m *Mutex) Header() *etcdserverpb.ResponseHeader
Header is the response header received from etcd on acquiring the lock.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session represents a lease kept alive for the lifetime of a client. Fault-tolerant applications may use sessions to reason about liveness.
func NewSession ¶
func NewSession(client *v3.Client, opts ...SessionOption) (*Session, error)
NewSession gets the leased session for a client.
func (*Session) Done ¶
func (s *Session) Done() <-chan struct{}
Done returns a channel that closes when the lease is orphaned, expires, or is otherwise no longer being refreshed.
type SessionOption ¶
type SessionOption func(*sessionOptions)
SessionOption configures Session.
func WithContext ¶
func WithContext(ctx context.Context) SessionOption
WithContext assigns a context to the session instead of defaulting to using the client context. This is useful for canceling NewSession and Close operations immediately without having to close the client. If the context is canceled before Close() completes, the session's lease will be abandoned and left to expire instead of being revoked.
func WithLease ¶
func WithLease(leaseID v3.LeaseID) SessionOption
WithLease specifies the existing leaseID to be used for the session. This is useful in process restart scenario, for example, to reclaim leadership from an election prior to restart.
func WithTTL ¶
func WithTTL(ttl int) SessionOption
WithTTL configures the session's TTL in seconds. If TTL is <= 0, the default 60 seconds TTL will be used.