2019-05-31 00:43:23 +01:00
|
|
|
// Package sync is a distributed synchronization framework
|
|
|
|
package sync
|
|
|
|
|
|
|
|
import (
|
2019-10-03 09:46:20 +01:00
|
|
|
"github.com/micro/go-micro/store"
|
2019-05-31 00:43:23 +01:00
|
|
|
"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"
|
|
|
|
)
|
|
|
|
|
2019-06-11 18:21:33 +01:00
|
|
|
// Map provides synchronized access to key-value storage.
|
2019-06-12 07:50:04 +01:00
|
|
|
// It uses the store interface and lock interface to
|
2019-05-31 00:43:23 +01:00
|
|
|
// provide a consistent storage mechanism.
|
2019-06-11 18:21:33 +01:00
|
|
|
type Map interface {
|
2019-05-31 00:43:23 +01:00
|
|
|
// 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
|
2019-06-12 07:50:04 +01:00
|
|
|
Store store.Store
|
2019-05-31 00:43:23 +01:00
|
|
|
Task task.Task
|
|
|
|
Time time.Time
|
|
|
|
}
|
|
|
|
|
|
|
|
type Option func(o *Options)
|