siegerts / drip

🚰 Watch and automatically restart Plumber APIs during development.
https://rdrip.netlify.app
Apache License 2.0
10 stars 1 forks source link

Usage from within docker for official plumber api example with entrypoint.R #2

Open mskyttner opened 3 years ago

mskyttner commented 3 years ago

I tried using drip in a container (see https://github.com/mskyttner/drip/blob/master/README-container.md) and have some questions/issues (which are hopefully possible to replicate using https://github.com/mskyttner/drip/blob/master/README-container.md#issues--questions).

The use case was to set up an container environment allowing live reload, by default using the plumber api example with an entrypoint that is bundled in the plumber R package.

I think I got it to run, but strangely the counter does not increment.

Any idea why?

siegerts commented 3 years ago

I'm happy that you're making use of the lib!

I'd probably need to dig in a bit but the first thing that comes to mind is that counter is trying persist across session. But in order for this to be reused- that session cookie needs to be reused by the client to make each subsequent request. If that's not happening then all requests at the server level appear distinct.

So, server creates session cookie -> passes to client -> client stores cookie -> client attaches cookie to next request.

Another way to test the counter is just to increment global state across all server requests or store that increment value into a persistent store/database.

mskyttner commented 3 years ago

Ah, of course! My curl command did not store or reuse cookies. Works great when I use a web browser. Thanks! That resolves my cookie confusion.

Onto the "runnable router" and entrypoint.R confusion. The docs here https://www.rplumber.io/reference/plumb.html implies there is now a convention that plumber uses an entrypoint.R file to return a "runnable router". And the drip also wants an "entrypoint.R" to start from, but in this case it needs a runnable router that has been started with $run()?

siegerts commented 3 years ago

Opened a new issue to track updates for plumber 1.x+. The current version was written when these conventions weren't yet in place.

mskyttner commented 3 years ago

:+1: