The purpose of this application is a case study of implementing event logging service in go.
Design and code based on this post: Handling 1 Million Requests per Minute with Go
EventService listens for HTTP POST requests on localhost:8080/log
- max_workers (default 20) - defines a number of concurrent workers for events processing.
- max_queue_size (default 500) - maximum number of events that can be buffered in the queue before processing.
- port (default 8080) - server port.
EventService stores events to PostgreSQL database.
Following parameters, cab be changed in Worker.go file
- host (default "localhost")
- port (default 5432)
- user (default "postgres")
- password (default "postgres")
- dbname (default "anoiio")
Required table can be created using /db/init.sql script
To start the application: $GOPATH/bin/eventservice
EventService supports 3 events types.
They can be submitted to the service by issuing HTTP POST request with the following body:
- Click
{
"type": "Click",
"payload": {
"date_time": 1502542550914,
"transaction_id": 11111,
"ad_type": "video",
"time_to_click": 5000,
"user_id": "fydsgf-t73r8nf"
}
}
- Impression
{
"type": "Impression",
"payload": {
"date_time": 1502542550914,
"transaction_id": 22222,
"ad_type": "video",
"user_id": "238rjhwefn-vmedo"
}
}
- Completion
{
"type": "Completion",
"payload": {
"date_time": 1502542550914,
"transaction_id": 33333,
"ad_type": "video",
"user_id": "7fh437fh3ug-rnbjr"
}
}