Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Running multiple Raisin apps on a single Plack server

by cLive ;-) (Prior)
on Jan 27, 2022 at 17:14 UTC ( #11140903=perlquestion: print w/replies, xml ) Need Help??

cLive ;-) has asked for the wisdom of the Perl Monks concerning the following question:

I'm loving Raisin as a framework for OpenAPI applications, but I've hit a wall and am needing some fresh eyes.

I want to spin up multiple Raisin apps on the same Plack server, something like this:

use Plack::Builder; use RaisinApp1; use RaisinApp2; builder { mount '/app1' => RaisinApp1->new(); mount '/app2' => RaisinApp2->new(); };

But, since Raisin is a functional framework, there's just a single application created, with the second "app" just being concatenated to the first, and with imported methods failing (eg, plugin) because they get imported into the first namespace that uses them.

I'm playing around with possible solutions, but nothing has stuck so far:

  • Reloading the entire Raisin::API module under a different namespace for each app (breaks helper methods in Raisin, so I'd have to rename all modules and code - way too messy)
  • Attempting to overload the "my" variables via an extra 'package Raisin::API' block (didn't think it would work, but worth a try - it didn't).

What I *think* I need is a way to load Raisin::API and it's dependencies in a scope limited way to lock it to each app's instance, but I can't think of how to do it. Would that be doable, or should I just drop the idea of trying to run multiple Raisin apps under Plack in this way? (yes, this is an odd setup, but it's transitional for a year or two while migrating away from a monolith)

Something like this:

my $app1 = some_scope_wrapper(sub { use Raisin::API; build_app1_here(); }); my $app2 = some_scope_wrapper(sub { use Raisin::API; build_app2_here(); }); # Raisin code won't work here...

Am I barking up the wrong tree, or just barking mad?

Replies are listed 'Best First'.
Re: Running multiple Raisin apps on a single Plack server
by Anonymous Monk on Jan 29, 2022 at 10:43 UTC
Re: Running multiple Raisin apps on a single Plack server
by etj (Chaplain) on Jan 28, 2022 at 21:40 UTC
    That's not necessarily an "or" question ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11140903]
Approved by philipbailey
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-10-02 12:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (8 votes). Check out past polls.

    Notices?