rendezvous

package
v0.0.0-...-9727c61 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSyncer

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

The FileSyncer creates a file when Ready is called. It then waits until the file is removed, which it treats as a signal that all other processes are ready as well, and returns from Ready. The FileSyncer is intended to be use together with another external process that waits until all files have been created and then removes them at once.

func NewFileSyncer

func NewFileSyncer(fileName string, pollInterval time.Duration) *FileSyncer

NewFileSyncer returns a new FileSyncer using a file with the given fileName.

func (*FileSyncer) Ready

func (fs *FileSyncer) Ready(ctx context.Context) error

Ready creates a file and periodically checks for the existence of the file with the configured pollInterval. Ready returns when that file has been removed, the context has been canceled, or an error occurred. Also, if the file already exists, prior to invocation, Ready immediately returns an error.

type Syncer

type Syncer interface {

	// Ready blocks until all other processes have called Ready() and then returns nil.
	// Ready returns an error when ctx is canceled or an error occurs.
	Ready(ctx context.Context) error
}

The Syncer serves the purpose of synchronizing multiple processes in time. Each process declares when it is ready to proceed and blocks. Only after all processes have declared readiness, all processes are released.

Jump to

Keyboard shortcuts

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