Skip to content

Instantly share code, notes, and snippets.

View RafaelFigueiredo's full-sized avatar

Rafael Figueiredo RafaelFigueiredo

  • Federal University of Rio de Janeiro
  • Rio de Janeiro, Brazil
View GitHub Profile
type Dispatcher struct {
// A pool of workers channels that are registered with the dispatcher
WorkerPool chan chan Job
}
func NewDispatcher(maxWorkers int) *Dispatcher {
pool := make(chan chan Job, maxWorkers)
return &Dispatcher{WorkerPool: pool}
}
func payloadHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
// Read the body into a string for json decoding
var content = &PayloadCollection{}
err := json.NewDecoder(io.LimitReader(r.Body, MaxLength)).Decode(&content)
var (
MaxWorker = os.Getenv("MAX_WORKERS")
MaxQueue = os.Getenv("MAX_QUEUE")
)
// Job represents the job to be run
type Job struct {
Payload Payload
}
@guillaumevincent
guillaumevincent / README.md
Last active April 28, 2024 00:51
Windows Service with Python 3.5 and pyinstaller
@hvasconcelos
hvasconcelos / gen_keys.sh
Last active September 19, 2023 23:14
Create an Sinatra SSL Server
# Generate a self-signed Certificate and a Private Key
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout pkey.pem -out cert.crt