synchub

package
v0.6.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSyncTimeout        = errors.New("timeout")
	ErrSyncHubForceClosed = errors.New("force closed")
	ErrSyncHubClosed      = errors.New("synchub closed")
	ErrSyncCanceled       = errors.New("sync canceled")
	ErrSyncIDResynced     = errors.New("id resynced")
	ErrTimerNotWorking    = errors.New("timer not working")
)

Functions

This section is empty.

Types

type Event

type Event struct {
	SyncID    interface{}
	Data, Ack interface{}
	Error     error
}

type Sync

type Sync interface {
	C() <-chan *Event
	Cancel(notify bool) bool
	Done() bool
	DoneSub(subSyncID interface{}) bool
	Ack(ack interface{}) bool
	Error(err error) bool
}

A Sync presents the handler of a synchronize.

type SyncHub

type SyncHub struct {
	// contains filtered or unexported fields
}

func NewSyncHub

func NewSyncHub(opts ...SyncHubOption) *SyncHub

func (*SyncHub) Ack

func (sh *SyncHub) Ack(syncID interface{}, ack interface{}) bool

func (*SyncHub) Add added in v0.2.2

func (sh *SyncHub) Add(syncID interface{}, opts ...SyncOption) Sync

func (*SyncHub) Cancel

func (sh *SyncHub) Cancel(syncID interface{}, notify bool) bool

func (*SyncHub) Close

func (sh *SyncHub) Close()

func (*SyncHub) Done

func (sh *SyncHub) Done(syncID interface{}) bool

Done finish the Sync, false means no such syncID

func (*SyncHub) DoneSub added in v0.2.4

func (sh *SyncHub) DoneSub(syncID interface{}, subSyncID interface{}) bool

DoneSubSyncID finish the partial Sync if other subSyncID exists or else to finish the complete Sync return false means syncID or subSyncID not found

func (*SyncHub) Error

func (sh *SyncHub) Error(syncID interface{}, err error) bool

func (*SyncHub) New

func (sh *SyncHub) New(syncID interface{}, opts ...SyncOption) Sync

deprecated

type SyncHubOption

type SyncHubOption func(*SyncHub)

func OptionTimer

func OptionTimer(tmr timer.Timer) SyncHubOption

type SyncOption

type SyncOption func(*synchronize)

Options for Sync

func WithCallback

func WithCallback(cb func(*Event)) SyncOption

Callback if perfered than channel

func WithContext added in v0.2.2

func WithContext(ctx context.Context) SyncOption

bad design, but still I want keep the capability

func WithData

func WithData(data interface{}) SyncOption

func WithEventChan

func WithEventChan(ch chan *Event) SyncOption

func WithSub added in v0.2.4

func WithSub(subSyncIDs ...interface{}) SyncOption

func WithTimeout

func WithTimeout(d time.Duration) SyncOption

Jump to

Keyboard shortcuts

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