Help us shape the future of Go! Take the 2026 Go Developer Survey

sync

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2018 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const RevisionCurrent = -1

RevisionCurrent is current sync revision

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Action   string
	Key      string
	Data     map[string]interface{}
	Revision int64
	// Err is used only by Sync.WatchContext()
	Err error
}

Event is a struct for Watch response

type Node

type Node struct {
	Key      string
	Value    string
	Revision int64
	Children []*Node
}

Node is a struct for Fetch response

type Sync

type Sync interface {
	HasLock(path string) bool
	Lock(path string, block bool) (notifyLost chan struct{}, err error)
	Unlock(path string) error
	Fetch(path string) (*Node, error)
	Update(path, json string) error
	Delete(path string, prefix bool) error
	// Watch monitors changes on path and emits Events to responseChan.
	// Close stopChan to cancel.
	// You can specify the revision to start watching,
	// give RevisionCurrent when you want to start from the current revision.
	// Returns an error when gets any error including connection failures.
	Watch(path string, responseChan chan *Event, stopChan chan bool, revision int64) error
	//WatchContext keep watch update under the path until context is canceled.
	WatchContext(ctx context.Context, path string, revision int64) <-chan *Event
	GetProcessID() string
	Close()
}

Sync is a interface for sync servers

Source Files

  • sync.go

Directories

Path Synopsis
Package mock_sync is a generated GoMock package.
Package mock_sync is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL