Skip to main content

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 wheelhouse.txt for reactive charms:

loadbalancer_interface

Usage

Requesting Load Balancers

Requesting a load balancer from a provider is done via the LBProvider class. The general pattern for using the class is:

  • Wait for the provider to become available
  • Get a Request object via the get_request(name) method
  • Set the appropriate fields on the request object
  • Send the Request via the send_request(request) method
  • Wait for the Response to be provided (or updated)
  • Get the Response object via either the get_response(name) method or via the new_responses property
  • Confirm that the request was successful and use the provided LB's address
  • Acknowledge the Response via ack_response(response)

There are examples in the repo for how to do this in an operator charm or in a reactive charm.

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 new_requests property
  • Create a load balancer according to the request's fields
  • Set the appropriate fields on the request's response object
  • Send the request's response via the send_response(request) method

There are examples in the repo for how to do this in an operator charm or in a reactive charm.

API Reference

See the API docs for detailed reference on the API.

Test Charms

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 files for loadbalancer-interface 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for loadbalancer-interface 1.2.1
File Size Uploaded
loadbalancer_interface-1.2.1.tar.gz 17.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for loadbalancer-interface 1.2.1
File Interpreter ABI Platform
loadbalancer_interface-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.2 kB

Release files / loadbalancer_interface-1.2.1.tar.gz

Download URL loadbalancer_interface-1.2.1.tar.gz
Size 17.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4a20b979122ed6e4e3f8d12feacdade2063415fbb40340ddd1fe0b1074a65e2b
BLAKE2b-256 checksum
How to use checksums
af0a1cbd5ef5501be133f609b972d7c69efa4e4f86ee9b9f40985fd5936f9399
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / loadbalancer_interface-1.2.1-py3-none-any.whl

Download URL loadbalancer_interface-1.2.1-py3-none-any.whl
Size 24.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11e37ea8952278cc5da3be8eddbc85809b4e4fd57ca8efae8762451221391a04
BLAKE2b-256 checksum
How to use checksums
8b41ca5eeef6e72f662ca2fd9fcbe0c128f9e3b43c201d9ed1defcdaf0046494
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.2

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page