Commit Graph

20 Commits

Author SHA1 Message Date
5e7a3480a1 Start prod config 2020-11-11 18:06:30 -05:00
9334c3a47d Get rid of log file 2020-11-11 18:06:13 -05:00
e44aa9ddfc Run server in docker container, added log file 2020-11-09 02:00:14 -05:00
5413fba309 Enable sqlx offline mode, add sqlx-data.json 2020-11-09 00:47:59 -05:00
780f0be433 Upgrade to sqlx 0.4 beta master branch
This required a ton of changes including updating error handling and separating out the models into intermediate representations so that fields that are marked non-null in the database are not `Option` in the final model.

The update allows using `query_as!` in `interior_ref_list` and `merchandise_list` and model functions to specify a generic `Executor` param that can take either a db pool connection, transaction, or plain db connection. This should allow me to impl my old `Model` trait again.

Also compile times are magically 20x faster?!?
2020-11-09 00:37:04 -05:00
1a1806ffc3 Initial docker setup using rust-musl-builder
Not working yet because sqlx 0.3 doesn't have an offline mode
2020-11-08 21:12:28 -05:00
2f69c86645 Add bincode format to endpointI'm testing out serializing data with bincode and using the Accept header to switch between formats for GET responses.If this works, I'll extend it to all endpoints and also add deserializing bincode from POST and PATCH requests. 2020-11-07 03:03:40 -05:00
a53eeffb0f Delay set cache after response, make cache static
Uses `tokio::spawn` to delay updating the cache while the server responds to the request.

Because `tokio::spawn` can run on another thread, references need to be static, so I initialized the cache in `lazy_static`.
2020-11-07 00:28:54 -05:00
8cb76d6ff4 Add ETag headers to get/list endpoints
Now the client can opt out of receiving the whole JSON body if it hasn't changed since they last requested.

Right now, only `ETag` and `If-None-Match` headers are implemeted which isn't very RFC-spec compliant but it's all I need so I don't care.
2020-11-02 20:22:12 -05:00
e831a925f5 Simplify db migrations
Use `refinery_cli` against a folder of `.sql` migrations.

I got tired of commenting out my code when I just wanted to rerun the initial migration.

Plain SQL is a lot more flexible than the `barrel` syntax.
2020-10-28 22:20:39 -04:00
db8ccb3ca4 Rename the project and add more README docs 2020-10-12 20:54:34 -04:00
170a3a8b02 Remove bytes dependency 2020-08-01 02:24:39 -04:00
519fcb4c5a Add caching with LRU cache under mutex
Caches responses of each GET handler in a separate capacity-limited cache (as a
custom clone-able `CachedResponse` struct). Subsequent requests will build a
`Response` from the cached bytes instead of re-querying the database and
re-serializing the JSON. This greatly speeds up the list endpoints and
`get_interior_ref_list`.

Also caches the api-key-to-id mapping for `Owner`s in order to speed up frequent
authentications.

Each create handler clears the entire list response cache. Each delete handler
also clears the entire list response cache and deletes the cached response for
that key. Deleting an owner also deletes their entry in the
`owner_ids_by_api_key` cache.
2020-08-01 00:25:04 -04:00
17cd3f12d2 Improve model query performance tracing 2020-07-28 22:01:57 -04:00
b16ba3e3f7 Swap out old log for shiny tracing 2020-07-27 22:36:48 -04:00
fb99afdc26 Encode/decode InteriorRef struct from jsonb column 2020-07-27 00:09:45 -04:00
65e6ba1f8a WIP adding interior_refs endpoints
Ran into some limitations of sqlx while trying to bulk create interior_refs. I
also discovered how slow creating hundreds of rows in postgres is and I'm
planning on saving interior_refs data in a jsonb column instead which seems to
be much faster.
2020-07-19 03:01:20 -04:00
9ec7fc1518 Modularize, Model trait, list_owners 2020-07-18 17:46:33 -04:00
aebcaf7d21 Working shops and owners create/get endpoints 2020-07-16 00:42:04 -04:00
91ff001c53 Initial commit. WIP shops endpoint
Pretty comfortable with the choice of crates now so it's time to start
committing.

Currently the API only returns errors, but throwing good errors is important.
2020-07-13 01:55:36 -04:00