singleinstance

package
v4.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleOnce

func HandleOnce(jobId string, instanceId string, handleCallback func(string), db *mongo.Database, ts timestamper.ITimeStamper, logger logger.ILogger) error

Call this to ensure this is handled ONCE among all API instances. It requires a "jobId", but this can be any unique string attributed to the task being handled. It also requires an instanceId (of this running API instance). Internally this works by writing our instance ID to DB, waiting a bit, then reading it back. If it wasn't overwritten by another API instance, we are the handler, and handleCallback is called, otherwise we see the instance ID is not ours and we stop further processing.

Types

This section is empty.

Jump to

Keyboard shortcuts

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