I’m experimenting with creating service plans that can serve as a lightweight place to stash the connection details for a pre-provisioned remote service and provide it to an application through binding just as if it was actually providing the service. The benefits of this approach over that currently recommended in Habitat documentation of making the bind optional and adapting your config to accept connection details via bind or config includes having more of a unified code path for config and being able to run an independent health check on the remote service
The only change you need to then make to the application’s config templates is to accept a manually-configured host before falling back to the bound service’s IP:
@predominant thanks for sharing! I really like your run script!
This is an interesting approach, one downside I can imagine though is that it seems like you couldn’t match the pkg_exports of the habitat-run service to provide drop-in replacement, as prefixes are needed to support multiple services. You could just configure the bind service to connect in-turn with the habitat-run service though.
Maybe this pattern could be helpful in creating a bind-sheet for complex applications that need multiple external services connected to multiple internal components, especially for composite plans since there’s no way currently to bind services to a composite. That way all the external components could be bound once to the “bind-service” within a composite plan, and then the composite plan could handle binding that to all the internal components that need it
Agreed. the samples that can be provided, and the bind-service that I linked are single-use.
Given a contract is tied to a plan very tightly, the approach you’ve taken with mysql-remote is correct, but I’m super wary about including such a pattern into core-plans. This opens the gates for *-remote doubling the number of packages. I think given the contract is simple, this can be left up to users to implement themselves, for each service they want to remote link.
One improvement I can think of is potentially including the run hook, or a separate bash script that forces that infinite loop, so that a binding service would include the “loop” package, and run its loop.sh to avoid having to rewrite this in every bind service / remote plan.
I’ve never messed with binding multiple members to the same slot but it would break my templated config if that block repeated so I put that in there to protect against that