gitee.com/liuxuezhan/go-micro-v1.18.0@v1.0.0/sync/sync.go (about)

     1  // Package sync is a distributed synchronization framework
     2  package sync
     3  
     4  import (
     5  	"gitee.com/liuxuezhan/go-micro-v1.18.0/store"
     6  	"gitee.com/liuxuezhan/go-micro-v1.18.0/sync/leader"
     7  	"gitee.com/liuxuezhan/go-micro-v1.18.0/sync/lock"
     8  	"gitee.com/liuxuezhan/go-micro-v1.18.0/sync/task"
     9  	"gitee.com/liuxuezhan/go-micro-v1.18.0/sync/time"
    10  )
    11  
    12  // Map provides synchronized access to key-value storage.
    13  // It uses the store interface and lock interface to
    14  // provide a consistent storage mechanism.
    15  type Map interface {
    16  	// Read value with given key
    17  	Read(key, val interface{}) error
    18  	// Write value with given key
    19  	Write(key, val interface{}) error
    20  	// Delete value with given key
    21  	Delete(key interface{}) error
    22  	// Iterate over all key/vals. Value changes are saved
    23  	Iterate(func(key, val interface{}) error) error
    24  }
    25  
    26  // Cron is a distributed scheduler using leader election
    27  // and distributed task runners. It uses the leader and
    28  // task interfaces.
    29  type Cron interface {
    30  	Schedule(task.Schedule, task.Command) error
    31  }
    32  
    33  type Options struct {
    34  	Leader leader.Leader
    35  	Lock   lock.Lock
    36  	Store  store.Store
    37  	Task   task.Task
    38  	Time   time.Time
    39  }
    40  
    41  type Option func(o *Options)