Closed CrowdHailer closed 5 years ago
Is there an init
call for middleware that’s called at server startup to allow us to start the supervisor and gen_server?
Raxx is just a library not an application. so there is no supervision tree to add it to.
Ace has a supervision tree but I would like it to be separate from raxx middleware
The date functionality needs a supervisor. Perhaps this goes in Ace?
I don't see why explicitly adding a supervisor would be much of a problem.
There could be a raxx_date
application that is not a library. which has it's own supervision tree but that seams rather to small a project to be standalone
Removed as not blocking anyone at the moment.
Waiting for a standard middleware format, or opinionatedly can just be handled in the server layer
Because looking up the time can be relatively expensive, we should not look it up for every request.
I suggest having a process that writes the date to an ets table every second. and other processes can read from this table to set the value in a response. This is how I think cowboy does it.
To start the writing process something like this should be added to the application supervision tree
This creates a named ets table called
:"raxx.date"
and writes to it every secondThe current date can be explicitly written to a response as follows
This looks up date from
:"raxx.date"
Calls to
set_date
can be wrapped up in a middleware.use Raxx.Date
that can be added to router/controller