Skip to content

Commit

Permalink
[management] /status/info endpoint
Browse files Browse the repository at this point in the history
that returns information about timers
  • Loading branch information
mikz committed Mar 14, 2017
1 parent 69ba232 commit d92cf03
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Backend HTTP client that uses cosockets [PR #295](https://github.com/3scale/apicast/pull/295)
- Ability to customize main section of nginx configuration (and expose more env variables) [PR #292](https://github.com/3scale/apicast/pull/292)
- Ability to lock service to specific configuration version [PR #293](https://github.com/3scale/apicast/pull/292)
- Experimental option for true out of band reporting (`APICAST_REPORTING_WORKERS`) [PR #290](https://github.com/3scale/apicast/pull/290)
- `/status/info` endpoint to the Management API [PR #290](https://github.com/3scale/apicast/pull/290)

### Removed

Expand Down
15 changes: 15 additions & 0 deletions apicast/src/management.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,28 @@ function _M.disabled()
ngx.exit(ngx.HTTP_FORBIDDEN)
end

function _M.info()
return json_response({
timers = {
pending = ngx.timer.pending_count(),
running = ngx.timer.running_count()
},
worker = {
exiting = ngx.worker.exiting(),
count = ngx.worker.count(),
id = ngx.worker.id()
}
})
end

local routes = {}

function routes.disabled(r)
r:get('/', _M.disabled)
end

function routes.status(r)
r:get('/status/info', _M.info)
r:get('/status/ready', _M.ready)
r:get('/status/live', _M.live)
end
Expand Down
10 changes: 10 additions & 0 deletions doc/management-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,13 @@ Available endpoints:
```json
{ "status": "live", "success": true }
```

- `GET /status/info`
Returns internal information about timers and workers.

```json
{
"timers": { "pending": 0, "running": 0 },
"worker": { "count":1, "exiting": false, "id": 0 }
}
```
16 changes: 16 additions & 0 deletions t/001-management.t
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,19 @@ POST /config
--- error_code: 406
--- no_error_log
[error]
=== TEST 16: status information
Has information about timers and time.
--- main_config
env APICAST_MANAGEMENT_API=status;
--- http_config
lua_package_path "$TEST_NGINX_LUA_PATH";
--- config
include $TEST_NGINX_MANAGEMENT_CONFIG;
--- request
GET /status/info
--- response_body
{"timers":{"pending":0,"running":0},"worker":{"count":1,"exiting":false,"id":0}}
--- error_code: 200
--- no_error_log
[error]

0 comments on commit d92cf03

Please sign in to comment.