Rate Limiting

GoCollaborate manages the API endpoints through Signature, as an obvious benefit, you can easily set a rate limiter for the specific service you are provisioning.

Entry

package main

import (
    "./core"
    "github.com/GoCollaborate/src"
    "time"
)

func main() {
    mp := new(core.SimpleMapper)
    rd := new(core.SimpleReducer)
    collaborate.Set("Function", core.ExampleFunc, "exampleFunc")
    collaborate.Set("Mapper", mp, "core.ExampleTask.Mapper")
    collaborate.Set("Reducer", rd, "core.ExampleTask.Reducer")
    collaborate.Set("Shared", []string{"GET", "POST"}, core.ExampleJobHandler)

    // this will allow the job service tokens to be refilled every 20 millisecond (50 requests per second)
    // at any time, the maximum number of job requests running in parallel is 20
    collaborate.Set("Limit", "/core/ExampleJobHandler", 20*time.Millisecond, 20)
    collaborate.Run()
}

When the request load exceeds the defined limit, GoCollaborate server will return an HTTP header with proper message to reject the API call:

Header Value
429 Too Many Requests

Body:

Job request exceeds the maximum handling limit, please try later.



results matching ""

    No results matching ""