Skip to content

Worker pools are a model in which a fixed number of m workers (implemented in Go with goroutines) work their way through n tasks in a work queue (implemented in Go with a channel). Work stays in a queue until a worker finishes up its current task and pulls a new one off.

Notifications You must be signed in to change notification settings

vaibhav2ghadge/go-worker-pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Implemented app by using SOLID principal and domain driven design

https://medium.com/learnfazz/domain-driven-design-in-go-253155543bb1

  • We can easily add and remove any part of code easily
  • Given csv file with hotel details we have to push into db and json file and it may happen that storing the output change like sqlite3 to mysql , json to xml so our code needs to be moduler and functional.
  • We observe that processing and pushing data into db slower the app. to slove this problem we build worker pool model. we have fix number of worker we pass data to worker and worker push it to the db.
  • Worker Pool Implementation

Library Used

  • go get github.com/mattn/go-sqlite3 used for sqlite3

Build and Installation

  1. make build #for build binary
  2. ./main -sqliteDBPath=/home/user/go/src/trivago/sqlite.db -inputFilePath=/home/user/go/src/trivago/delivery/hotels.csv -jsonFilePath=/home/user/go/src/trivago/utils/op.json -workers=10

Also added build for linux in directory builds if faild to build

About

Worker pools are a model in which a fixed number of m workers (implemented in Go with goroutines) work their way through n tasks in a work queue (implemented in Go with a channel). Work stays in a queue until a worker finishes up its current task and pulls a new one off.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published