Commit Graph

66 Commits

Author SHA1 Message Date
Daniel Sockwell e1257146cd Close Redis connections when SSE stream ends
This commit tracks the existence of the SSE stream and closes the
connection to the redis pub/sub channel when the stream is closed.  This
prevents the number of redis connections from growing over time.

Note, however, that the current code still subscribes to one redis
channel per SSE connection rather than reusing existing subscriptions.
This will need to be fixed in a later PR.
2019-04-21 09:21:44 -04:00
Daniel Sockwell 5011abaf77 Add language and notification filters 2019-04-19 17:06:29 -04:00
Daniel Sockwell ff957bd407 Minor refactoring
Improved clarity, concision, and ergonomics of the codebase.
2019-04-19 12:16:03 -04:00
Daniel Sockwell 6746514f9a Finish building out postgres auth 2019-04-18 19:02:29 -04:00
Daniel Sockwell debf01770e Complete header-based auth 2019-04-18 17:07:31 -04:00
Daniel Sockwell 13d9cf17f6 Connect to postgres for basic auth 2019-04-18 15:47:08 -04:00
Daniel Sockwell 9434260fa7 Add logging with `pretty_env_log`
This commit adds basic logging at both the `info` level (for establishing
a new stream) and at the `debug` level (for streaming JSON).
2019-04-18 10:10:01 -04:00
Daniel Sockwell 23eaa4a270 Implement basic Server Sent Events with Warp
This commit rolls up several days of work that took place in a side repo
which was originally intended to be a test/proof-of-concept repo but
that grew into a full implementation.

This implementation switches to Warp as the framework for the primary
web server (in large part because Warp offers built-in support for
SSE and several other advantages).  This implementation relies on
a custom Redis interface built on Tokio (because the current Redis
Rust crate does not support asnyc PubSub).  Using a custom interface
should also be faster, since it does not contain logic for anything
other than pubsub—which is all we need.

Finally, I note that the SSE support is currently as feature-complete
as it is possible to be without having yet added the Postgress interface
this means that all of the endpoints are present and are accessible
on localhost.  However, none of the endpoints have authentication yet,
and the endpoints that should provide user-specific data (e.g.,
`/api/v1/streaming/user`) are currently hard-coded to provide data for
user 1 (the admin).  Other than those limitations, however, the SSE
implementation is feature complete.
2019-04-15 14:22:44 -04:00
Daniel Sockwell 4842475b18 Rustfmt all code
Revise all code to comply with rustfmt
2019-03-05 09:23:44 -05:00
Julian Laubstein bfec0327d6 Use redis environment for connection 2019-02-19 22:57:01 +01:00
Julian Laubstein dfafec963b Added structures for env variables 2019-02-19 20:29:32 +01:00
Julian Laubstein dcc0283078 Fixed cors and added health endpoint 2019-02-15 22:59:21 +01:00
Julian Laubstein 88492aac36 Lots of basic stuff 2019-02-15 10:22:35 +01:00
Julian Laubstein 524935c441 Added all routes as mock 2019-02-11 21:00:07 +01:00
Julian Laubstein 1339784112 Added all endpoints 2019-02-11 18:58:51 +01:00
Julian Laubstein 7caa714891 Initial project files 2019-02-11 09:45:14 +01:00