'loadbalancer' interface protocol API library
loadbalancer Interface Protocol API Library
This library provides an API for requesting and providing load balancers or ingress endpoints from one charm to another. It can be used in either charms written in the newer Operator Framework or older charms still using the charms.reactive Framework.
Installation / Setup
Include this library as a dependency for your charm, either in
requirements.txt for Operator Framework charms, or
Requesting Load Balancers
Requesting a load balancer from a provider is done via the
The general pattern for using the class is:
- Wait for the provider to become available
- Get a
Requestobject via the
- Set the appropriate fields on the request object
- Send the
- Wait for the
Responseto be provided (or updated)
- Get the
Responseobject via either the
get_response(name)method or via the
- Confirm that the request was successful and use the provided LB's address
- Acknowledge the
Providing Load Balancers
Providing a load balancer to consumers is done via the
LBConsumers class. The
general pattern for using the class is:
- Wait for new or updated requests to come in
- Iterate over each request object in the
- Create a load balancer according to the request's fields
- Set the appropriate fields on the request's
- Send the request's response via the
See the API docs for detailed reference on the API.
To ease testing of charms using this interface, this library provides test charms which can be used with the pytest-operator plugin based integration test to serve as a basic counterpart to the charm providing or requiring this interface.
The charms are accessed via an
lb_charms fixture, which is session scoped.
The fixture provides an object with attributes for each of the example
charms available in the repo. (The attribute names will be the charm names
with dashes replaced with underscores.) For example:
async def test_build_and_deploy(ops_test, lb_charms): my_charm = await ops_test.build_charm(".") lb_provider = await ops_test.build_charm(lb_charms.lb_provider) await ops_test.model.deploy(my_charm) await ops_test.model.deploy(lb_provider) await ops_test.model.add_relation("my-charm", "lb-provider")
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for loadbalancer_interface-1.1.2.tar.gz