Add sync => go-sync

This commit is contained in:
Asim Aslam
2019-05-31 00:43:23 +01:00
parent 4035ab5c7b
commit 95d134b57e
28 changed files with 2192 additions and 0 deletions

41
sync/sync.go Normal file
View File

@@ -0,0 +1,41 @@
// Package sync is a distributed synchronization framework
package sync
import (
"github.com/micro/go-micro/sync/data"
"github.com/micro/go-micro/sync/leader"
"github.com/micro/go-micro/sync/lock"
"github.com/micro/go-micro/sync/task"
"github.com/micro/go-micro/sync/time"
)
// DB provides synchronized access to key-value storage.
// It uses the data interface and lock interface to
// provide a consistent storage mechanism.
type DB interface {
// Read value with given key
Read(key, val interface{}) error
// Write value with given key
Write(key, val interface{}) error
// Delete value with given key
Delete(key interface{}) error
// Iterate over all key/vals. Value changes are saved
Iterate(func(key, val interface{}) error) error
}
// Cron is a distributed scheduler using leader election
// and distributed task runners. It uses the leader and
// task interfaces.
type Cron interface {
Schedule(task.Schedule, task.Command) error
}
type Options struct {
Leader leader.Leader
Lock lock.Lock
Data data.Data
Task task.Task
Time time.Time
}
type Option func(o *Options)