go-platform: github.com/micro/go-platform/sync Index | Files

package sync

import "github.com/micro/go-platform/sync"

Package sync is an interface for synchronization.

Index

Package Files

context.go options.go sync.go

Variables

var (
    DefaultNamespace = "/micro/sync"
)

func NewContext Uses

func NewContext(ctx context.Context, c Sync) context.Context

type Elected Uses

type Elected interface {
    // Returns a channel which indicates
    // when the leadership is revoked
    Revoked() (chan struct{}, error)
    // Resign the leadership
    Resign() error
}

type Leader Uses

type Leader interface {
    // The unique ID to synchronize with
    Id() string
    // Returns the current leader
    Leader() (*registry.Node, error)
    // Elect self to become leader
    Elect() (Elected, error)
    // Returns the status of this node
    Status() (LeaderStatus, error)
}

type LeaderOption Uses

type LeaderOption func(o *LeaderOptions)

type LeaderOptions Uses

type LeaderOptions struct{}

type LeaderStatus Uses

type LeaderStatus int32
const (
    FollowerStatus  LeaderStatus = 0
    CandidateStatus LeaderStatus = 1
    ElectedStatus   LeaderStatus = 2
)

type Lock Uses

type Lock interface {
    // The unique ID to lock on
    Id() string
    // Acquire the lock
    Acquire() error
    // Release the lock
    Release() error
}

type LockOption Uses

type LockOption func(o *LockOptions)

func LockTTL Uses

func LockTTL(t time.Duration) LockOption

func LockWait Uses

func LockWait(t time.Duration) LockOption

type LockOptions Uses

type LockOptions struct {
    TTL  time.Duration
    Wait time.Duration
}

type Option Uses

type Option func(o *Options)

func Namespace Uses

func Namespace(n string) Option

func Nodes Uses

func Nodes(nodes ...string) Option

func Service Uses

func Service(s *registry.Service) Option

type Options Uses

type Options struct {
    Namespace string
    Service   *registry.Service
    Nodes     []string
}

type Sync Uses

type Sync interface {
    // distributed lock interface
    Lock(id string, opts ...LockOption) (Lock, error)
    // leader election interface
    Leader(id string, opts ...LeaderOption) (Leader, error)
    // Name of sync
    String() string
}

func FromContext Uses

func FromContext(ctx context.Context) (Sync, bool)

Package sync imports 3 packages (graph) and is imported by 5 packages. Updated 2018-02-20. Refresh now. Tools for package owners.