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.1.tar.gz (160.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.1-cp38-abi3-win_amd64.whl (4.1 MB view details)

Uploaded CPython 3.8+Windows x86-64

junction_python-0.1.1-cp38-abi3-musllinux_1_2_x86_64.whl (5.1 MB view details)

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

junction_python-0.1.1-cp38-abi3-musllinux_1_2_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.8+musllinux: musl 1.2+ ARM64

junction_python-0.1.1-cp38-abi3-manylinux_2_24_aarch64.whl (4.9 MB view details)

Uploaded CPython 3.8+manylinux: glibc 2.24+ ARM64

junction_python-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.0 MB view details)

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

junction_python-0.1.1-cp38-abi3-macosx_11_0_arm64.whl (4.4 MB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

junction_python-0.1.1-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.1.tar.gz.

File metadata

  • Download URL: junction_python-0.1.1.tar.gz
  • Upload date:
  • Size: 160.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.1.tar.gz
Algorithm Hash digest
SHA256 cf59cd1d227b295f027a546c0a29556e6cecc29c6872c60dffda4b1adc42d20c
MD5 cab594a25910e17e42252734e5eab70e
BLAKE2b-256 d532f219f1180a3ce9de9532034aa1d666055946117c2a1ff20ceb9e88eb7428

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.1.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.1-cp38-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.1-cp38-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3fd0850ab0b03d94e94838fe1ee6cae76b53845aeb31ad745af78f72228dc30b
MD5 f7293b80551223912ef45ad83766a4be
BLAKE2b-256 efadd5b1517ba63fc4ad92f084744a10766187240e63e3d5da7a42f5a670ff1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.1-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.1-cp38-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.1-cp38-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8ac60eba662850ea0d5701ebc1d27146d82b94971afc35be73a4edb9a4fc0456
MD5 7825d6e2f24f118c2196759d808ca12c
BLAKE2b-256 06cabcc863d3cdfa39c7f46b098ece5b6a85baa2010f00381d468fe7199c8611

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.1-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.1-cp38-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.1-cp38-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 cd790843e2f555e56bf0602ecbd5a4800d316e761fd054fc0a16a037db6dc4c1
MD5 d1a7e5df9ced2adee37ec1e5198da64f
BLAKE2b-256 0eb11ab400c3ee044bc7a635dee4c9deb9f627be4eedd4651f2168c71966945a

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.1-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.1-cp38-abi3-manylinux_2_24_aarch64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.1-cp38-abi3-manylinux_2_24_aarch64.whl
Algorithm Hash digest
SHA256 9c08c1e63a83ca31974c66daad2b80e43486fc3e665ce7c843257dd265166316
MD5 1d0be4d7d771826838233f41b99e0324
BLAKE2b-256 429d69d77faabd015ff41d4f75412a11930412a07a112ea2f01d64f7d18d0eae

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.1-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.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.1-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2ac25c724ea403ccffac411e571290d97bc7421c12a27a7f643f8007271f7518
MD5 0706bb3dd7349aef4a674bba70e70c90
BLAKE2b-256 b7e9cba195b2deba3385a0786d1206bfa49b721e0ab0928ee63bb665556b90f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.1-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.1-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.1-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3bd55ab04043e37d9922c06704ee44f8f40b602b64da059ad3d3a6071643bf88
MD5 af4dde62f751318994236aa5e2a527e5
BLAKE2b-256 be6b56442721f63bfa1b20276115ba6d36964aff7d384631d46fa91e3bd0a197

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.1-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.1-cp38-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for junction_python-0.1.1-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3cc1bdb5fe319be7d420d91c62c5b860e5126e6309c9af3434e36ad336eb25a1
MD5 3c0434f41479d71f07ae51f032d089ae
BLAKE2b-256 2365adeb579e4cac8753be9a3c6fefba4dc0d13859b375303d096b2cd2c9e280

See more details on using hashes here.

Provenance

The following attestation bundles were made for junction_python-0.1.1-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