Skip to content

Configure integrations

An Orionis application starts with an empty list of permitted destinations. To call a catalog API, authorize its origin (scheme, hostname and optional port) and give it a profile name. Your application can then use Http.client("catalog").get("/products/42"). Use the same profile in every environment and change its origin in the project’s configuration.

From the application directory that contains reactor, run the following command in the project’s Python environment. It creates the missing file and preserves an existing one.

Terminal window
python -B reactor bootstrap:config http_client

In config/http_client.py, set allowed_origins and clients on BootstrapHttpClient. Here is a complete minimal file. The remaining values come from the framework. Replace the example host with the real service before making a network call. The first request also works with the example host and a fake.

from dataclasses import dataclass, field
from orionis.foundation.config.http_client import HttpClientConfig
@dataclass(frozen=True, kw_only=True)
class BootstrapHttpClient(HttpClientConfig):
allowed_origins: tuple[str, ...] = ("https://catalog.example.com",)
clients: dict[str, dict[str, object]] = field(
default_factory=lambda: {
"catalog": {"base_url": "https://catalog.example.com"},
}
)

A request for /products/42 using catalog now targets https://catalog.example.com/products/42. An allowed origin alone permits an absolute URL or Http.baseUrl(...). Registering a profile additionally lets callers use its name and share integration settings.

  • https://catalog.example.com:8443 is a separate origin. Include it explicitly if the service listens on that port. An explicit HTTPS port 443 is equivalent to the default.
  • Put version prefixes such as /v2 in the endpoint path. Orionis accepts only the origin in base_url and allowed_origins. Subdomains also have their own origins.
  • Use https:// and a specific host. A URL containing credentials, query parameters or a fragment does not belong in the origin list. If a host has multiple addresses, configure DNS and outbound network access for your deployment as well.
  • Store non-secret defaults in profile headers. Profiles enter the application’s compiled configuration. Supply API keys and tokens on a bound request at runtime. Headers and authentication

Suppose product search is optional and a page should spend at most four seconds waiting for it. Replace only the clients field in the class above with the following. Existing callers keep their catalog settings. Search callers use Http.client("catalog_search"), which uses the same origin and gets a shorter connection timeout, a four-second overall deadline and a 256 KiB response limit.

clients: dict[str, dict[str, object]] = field(
default_factory=lambda: {
"catalog": {"base_url": "https://catalog.example.com"},
"catalog_search": {
"base_url": "https://catalog.example.com",
"headers": {"Accept": "application/json"},
"connect_timeout": 1.0,
"deadline": 4.0,
"max_response_bytes": 262_144,
},
}
)

Each profile requires base_url. Its optional keys are headers, connect_timeout, read_timeout, write_timeout, pool_timeout, deadline, max_request_bytes and max_response_bytes. Any override may equal or tighten the application limit. Connection counts, idle lifetime and admission limits belong to the whole application. Use a short identifier such as catalog_search and pass its exact spelling to client().

Set these fields directly on BootstrapHttpClient to change them for all clients. Durations are positive finite numbers in seconds. Byte and capacity limits use integers.

FieldDefaultWhat the setting controls
allowed_origins()Exact HTTPS origins that requests may contact. Accepts a tuple or list.
clients{}Named profiles, keyed by the name passed to client().
connect_timeout5.0Time available to establish a connection.
read_timeout5.0Maximum inactivity while waiting for response data.
write_timeout5.0Maximum inactivity while sending request data.
pool_timeout2.0Time to acquire a connection from the pool.
deadline15.0Total time for the call, including admission, preparation and reading the response.
max_request_bytes1_048_576 (1 MiB)Maximum encoded request body.
max_response_bytes4_194_304 (4 MiB)Maximum buffered response body.
max_connections32Maximum connections per event loop.
max_keepalive_connections16Number of idle connections to retain, from zero to max_connections.
keepalive_expiry5.0Maximum idle lifetime of a reusable connection.
max_in_flight32Maximum active operations per event loop.
max_pending64Maximum operations waiting for admission. Zero rejects overflow immediately.

Both byte limits, max_connections and max_in_flight must be at least one. For per-call adjustments, use timeout(), connectTimeout() or deadline() on a chain. Concurrency and deadlines

If your project owns its policy in bootstrap/app.py, apply the same fields to its application instance before app.create().

app.withConfigHttpClient(
allowed_origins=["https://catalog.example.com"],
clients={"catalog": {"base_url": "https://catalog.example.com"}},
)

During a cold configuration load, discovered configuration files take precedence over fields supplied through the setters. Choose one place to own the policy. For example, a discovered BootstrapHttpClient with an empty allowed_origins can override the list supplied in bootstrap code. Restart a running process after changing its configuration. If your application uses a compiled snapshot, check its configured invalidation paths. How configuration loads

An invalid profile or a misspelled profile name raises HttpConfigurationException. For a startup error, check the origin, field names and limits before investigating the network. If an individual send raises HttpDestinationException, check the destination selected by that call. Send requests