Skip to main content

An embeddable, dynamically configurable HTTP library

Project description

junction-client

An embeddable, dynamically configurable HTTP library.

About

Junction is a library that allows you to dynamically configure application level HTTP routing, load balancing, and resilience by writing a few lines of configuration and dynamically pushing it to your client. Imagine having all of the features of a rich HTTP proxy that's as easy to work with as the HTTP library you're already using.

Junction can be statically configured, with plain old software, or dynamically configured with any gRPC-xDS compatible configuration server. Check out ezbake for a simple server that lets you save Junction config using the Kubernetes Gateway API

Project status

Junction is alpha software, developed in the open. We're still iterating rapidly on core code and APIs. At this stage you should expect occasional breaking changes as the library evolves. At the moment, Junction only supports talking to Kubernetes services, with support for routing to any existing DNS name coming very soon.

Features

Junction allows you to statically or dynamically configure:

  • Routing traffic to backends based on the HTTP method, path, headers, or query parameters.
  • Timeouts
  • Retries
  • Weighted traffic splitting
  • Load balancing

Junction differs from existing libraries and proxies in that we aim to do all of this in your native programming language, with low overhead and deep integration into your existing HTTP client. This approach means that Junction can provide dynamic config, but still provide first class support for things like unit testing and debugging, putting developers back in control of their applications.

Roadmap

We're starting small and focused with Junction. Our first goal is getting configuration right. Our next goal is allowing you to push configuration that you've developed and tested to a centralized config server.

Supported Languages and HTTP Libraries

Language Core Library Supported HTTP Libraries
Rust junction-core None
Python junction requests and urllib3

Using a Junction client

Junction clients are part of your application and function as a cache for dynamic configuration. All Junction clients can also be configured with static configuration that acts as a default when a server doesn't have any dynamic configuration for a route or a target. When you make an HTTP request, Junction matches it against existing configuration, decides where and how to send the request, and then hands back control to your HTTP library.

In all of our libraries, Junction clients expect to be able to talk to a dynamic configuration server. The details of how you specify which config server to talk to are specific to each language - we want it to feel natural.

If you don't already have a gRPC-compatible xDS server available, try installing ezbake in your local Kubernetes cluster.

Python

In Python, Junction is available as a standalone client and as a drop-in replacement for requests.Session or urllib3.PoolManager.

Using junction as a drop-in replacement for requests is as easy as:

import junction.requests as requests

session = requests.Session()
resp = session.get("http://my-service.prod.svc.cluster.local")

To configure your client, pass default_routes or default_backends to your Session. For example, to load-balance requests to an nginx service in the web namespace based on the x-user header, you can specify:

import junction.requests as requests

# create a new Session with a default load balancing policy for the nginx service
session = requests.Session(
    default_backends=[
        {
            "target": {"type": "service", "name": "nginx", "namespace": "web"},
            "lb": {
                "type": "RingHash",
                "hash_params": [
                    {"type": "Header", "name": "x-user"},
                ],
            },
        }
    ]
)

# make a request to the nginx service
session.get("http://nginx.web.svc.cluster.local")

Routes can be configured by default as well. To send all requests to /v2/users to a different version of your application, you could set a default configuration like:

import junction.config
import typing

import junction.requests as requests

my_service = {"type": "service", "name": "cool", "namespace": "widgets"}
my_test_service = {"type": "service", "name": "cooler", "namespace": "widgets"}

# create a new routing policy.
#
# all Junction config comes with python3 type hints, as long as you import junction.config
routes: typing.List[junction.config.Route] = [
    {
        "target": my_service,
        "rules": [
            {
                "backends": [my_test_service],
                "matches": [{"path": {"value": "/v2/users"}}],
            },
            {
                "backends": [my_service],
                "retry": retry_policy,
                "timeouts": timeouts,
            },
        ],
    },
]


# assert that requests with no path go to the cool service like normal
(_, _, matched_backend) = junction.check_route(
    routes, "GET", "http://cool.widgets.svc.cluster.local", {}
)
assert matched_backend["name"] == "cool"

# assert that requests to /v2/users go to an even cooler service
(_, _, matched_backend) = junction.check_route(
    routes, "GET", "http://cool.widgets.svc.cluster.local/v2/users", {}
)
assert matched_backend["name"] == "cooler"

# use the routes we just tested in our HTTP client
s = requests.Session(default_routes=routes)

For a more complete example configuration see the sample project. It's a runnable example containing routing tables, load balancing, retry policies, and more.

NodeJS

NodeJS support is coming soon! Please reach out to info@junctionlabs.io if you run NodeJS services and are interested in being an early access design partner.

Rust

The core of Junction is written in Rust and is available in the junction-core crate. At the moment, we don't have an integration with an HTTP library available, but you can use the core client to dynamically fetch config and resolve addresses.

See the examples directory for an example of how to use junction to resolve an address.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

junction_python-0.1.0.tar.gz (151.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

junction_python-0.1.0-cp38-abi3-win_amd64.whl (4.0 MB view details)

Uploaded CPython 3.8+Windows x86-64

junction_python-0.1.0-cp38-abi3-musllinux_1_2_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ x86-64

junction_python-0.1.0-cp38-abi3-musllinux_1_2_aarch64.whl (5.0 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

junction_python-0.1.0-cp38-abi3-manylinux_2_24_aarch64.whl (4.8 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.24+ ARM64

junction_python-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.9 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

junction_python-0.1.0-cp38-abi3-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

junction_python-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.8+macOS 10.12+ x86-64

File details

Details for the file junction_python-0.1.0.tar.gz.

File metadata

  • Download URL: junction_python-0.1.0.tar.gz
  • Upload date:
  • Size: 151.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for junction_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ab052112fb4c638d874720a2bd8f6dfde3f50fb3f0ee9400d2e364ef20265a9d
MD5 d274187d5ae9fb398fbdd34c3f651891
BLAKE2b-256 6a61b6e2a874407b2023745767158ec0ed0a96a4e3e8c86fc73db489966b9d31

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.0.tar.gz:

Publisher: release-python.yaml on junction-labs/junction-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file junction_python-0.1.0-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.0-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 039b5fc4626264a60365d00b35e7401722c4f6287d748025ec76132bb4a087d8
MD5 94d6aedad6383679ca4d90d6265b13a5
BLAKE2b-256 7794074df326593d3f206f530cefeb35cb0a05fd82ef9b49861327b97581947d

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.0-cp38-abi3-win_amd64.whl:

Publisher: release-python.yaml on junction-labs/junction-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file junction_python-0.1.0-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.0-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1c3ce33e6ed5ed3a9507b2e250bdf239c128efd5f4d09261e692b0b0a396944d
MD5 cf2d013bf918d9e6ba70f2fd48a33350
BLAKE2b-256 d307351e3b40e4a7dacc76c5a0a3040da1f34a38f5e7901b781e29432590c67a

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.0-cp38-abi3-musllinux_1_2_x86_64.whl:

Publisher: release-python.yaml on junction-labs/junction-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file junction_python-0.1.0-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.0-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 0bba7e2d5659ea8b46236964471bf1749e0334bea8873423e33fc9d9c00026ee
MD5 71b738009bfd8feff348ed42cf6bb852
BLAKE2b-256 784943efd09ad58e351d0edd328a4437777ff25e001cc468b765c2a5f09e0ea8

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.0-cp38-abi3-musllinux_1_2_aarch64.whl:

Publisher: release-python.yaml on junction-labs/junction-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file junction_python-0.1.0-cp38-abi3-manylinux_2_24_aarch64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.0-cp38-abi3-manylinux_2_24_aarch64.whl
Algorithm Hash digest
SHA256 07db91cc780e40135327b75589dafb16dd3aceaa54f41b3c3a67ef7e388a2aba
MD5 3fb2a1ef1708cb1507232e522ed95288
BLAKE2b-256 efcb2ebffa5950e739290f8a18f53c8489ee39c860f33c0d04ef6c2f1ed81adc

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.0-cp38-abi3-manylinux_2_24_aarch64.whl:

Publisher: release-python.yaml on junction-labs/junction-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file junction_python-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 61557841400343a42291ba822f63503270663141379dd79fac47c84aa8ebbe61
MD5 fff597795311e825c3eb7e6e69af29b3
BLAKE2b-256 f429580fa6dad64ace6a79a5e21fa079446bd3032b13da47de47cc98978f4ac4

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-python.yaml on junction-labs/junction-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file junction_python-0.1.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a57602e98d775d64a28318a56f173f1448741eb7ace23434172bd6b62e7d307
MD5 d4cb93a2fe6a02c72bd87679e242f4ed
BLAKE2b-256 8655634a25d27448314fe904352f80fb8683f71d1a80419698354fe2e7ae73c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.0-cp38-abi3-macosx_11_0_arm64.whl:

Publisher: release-python.yaml on junction-labs/junction-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file junction_python-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 fa386186d4a9ddf60db80045b4fab6403d979053aaefcad059c20bf2c643a5ad
MD5 4eec74d01a9aaa140c8fe87cae4545d9
BLAKE2b-256 6abc0ef7930c4fb508dd3badbb4d11a645d06f85ec5f25fed51334dc5c6d754c

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl:

Publisher: release-python.yaml on junction-labs/junction-client

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page