I hereby claim:
- I am rishabh-gupta2 on github.
- I am rishabhgupta2 (https://keybase.io/rishabhgupta2) on keybase.
- I have a public key ASBs3BJ5ukrmij39wb9afa2sQz-KP1sEDxTuUIPAJQiRIgo
To claim this, I am signing this object:
// Store provides an interface for persisting and reading jobs. | |
type Store interface { | |
// FindPendingJobsToProcess reads new jobs to be processed, | |
// and marks them as processing atomically. | |
FindPendingJobsToProcess(ctx context.Context, jobBatchSize int32, jobProcessingTimeout time.Duration) ([]*Job, error) | |
// FindFailedJobsToProcess reads failed jobs to be processed again, | |
// and marks them as processing atomically. | |
FindFailedJobsToProcess(ctx context.Context, jobBatchSize int32) ([]*Job, error) |
// JobHandler is anything that can be sent using outboxer. | |
type JobHandler interface { | |
// Name returns a unique name for each handler. | |
// Unique name for each handler is a constraint, | |
// otherwise it will fail at the time of registration. | |
Name() string | |
// Handle is responsible for implementation-specific handling of jobs. | |
// Implementations need to ensure atomicity and graceful handling | |
// of out-of-order events. |
type Outboxer interface { | |
// Send expects an active gorm transaction alongwith | |
// a registered JobHandler and creates a new outbox job. | |
Send(context.Context, *gorm.DB, JobHandler) error | |
// Start initiates fetcher and processor goroutines to pick up and | |
// process persisted outbox jobs. | |
Start(context.Context) | |
// Stop gracefully terminates all the outbox goroutines. |
// Encoder holds the details on JobHandler which are registered with Outboxer. | |
// and is responsible for serialization and deserialization of JobHandler. | |
type Encoder interface { | |
// Encode serialize any registered interface to a string. | |
Encode(handler interface{}) (string, error) | |
// Decode deserialize a valid encoded string to its interface. | |
Decode(content string) (interface{}, error) | |
// Register registers interfaces which will be serialized. |
type Job struct { | |
Id string `json:"id"` | |
CreatedAt int64 `json:"created_at"` | |
UpdatedAt int64 `json:"updated_at"` | |
HandlerName string `json:"handler_name"` | |
Status JobStatus `json:"status" sql:"DEFAULT:pending"` | |
HandlerSerialized string `json:"handler_serialized"` | |
NextAttemptAt int64 `json:"next_attempt_at"` | |
NumAttempts int `json:"num_attempts"` | |
} |
// Config holds configs for outboxer. | |
type Config struct { | |
// ProcessorPoolSize is the number of processor goroutines | |
// which will Process outboxed jobs. | |
ProcessorPoolSize int | |
// JobProcessingTimeoutMs is the maximum time a job is expected to take | |
// time to process. After which it will be picked again for processing. | |
JobProcessingTimeoutMs int32 |
I hereby claim:
To claim this, I am signing this object: