Skip to content

Eddie023/microbatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MicroBatcher: Go Micro-Batching Library

  1. Simple Microbatching example written in golang.

Usage

  1. Create struct that implements BatchProcessor Interface such as
type YourBatchProcessor struct {}

func (p *YourBatchProcessor) Process (job microbatch.Job) (microbatch.JobResult, error) {
    return microbatch.JobResult{
        Result: nil, 
        JobId: 1,
    }, nil 
}
  1. Initiate a new Microbatcher using Factory function. Provide required such as "batchSize" , "frequency" and your batch Processor that you created above.
  mb := microbatch.NewMicroBatch(batchSize, yourBatchProcessor, frequency)
  1. Create a channel to get your successfully ran job results.
  jobResult := make(chan microbatch.JobResult{})
  1. Start MicroBatcher and pass your job result channel.
  mb.Run(context.Background(), jobResult)
  1. Add Jobs to your microbatcher
  mb.Submit(microbatch.Job{Id: 1, Task: 10})

For a full implementation with optional configuration, please checkout the example provided in the repo.

About

Micro-batching implementation in Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages