pyramid_blacksmith.binding¶
- class pyramid_blacksmith.binding.SettingsBuilder(settings: Mapping[str, str], metrics: PrometheusMetrics, prefix: str = 'client')¶
- class pyramid_blacksmith.binding.BlacksmithPrometheusMetricsBuilder(settings: Mapping[str, str])¶
Create the prometheus metric object from the settings.
Because the prometheus_client don’t want to create multiple time, the same metrics, the build() will return the first PrometheusMetrics created, event if it has been called with different settings.
This simplify tests, and it is not supposed to be a use case.
- build() PrometheusMetrics ¶
Return the first PrometheusMetrics object build from the settings passed.
- class pyramid_blacksmith.binding.BlacksmithClientSettingsBuilder(settings: Mapping[str, str], metrics: PrometheusMetrics, prefix: str = 'client')¶
- build() SyncClientFactory[Any] ¶
- build_sd_static() SyncStaticDiscovery ¶
- build_sd_consul() SyncConsulDiscovery ¶
- build_sd_nomad() SyncNomadDiscovery ¶
- build_sd_router() SyncRouterDiscovery ¶
- build_sd_strategy() SyncAbstractServiceDiscovery ¶
- get_timeout() HTTPTimeout ¶
- get_proxies() URL | str | Proxy | Dict[URL | str, None | URL | str | Proxy] | None ¶
- get_verify_certificate() bool ¶
- build_transport() SyncAbstractTransport | None ¶
- build_collection_parser() type[CollectionParser] ¶
- build_error_parser() AbstractErrorParser[Any] ¶
- build_middlewares(metrics: PrometheusMetrics) Iterator[SyncHTTPMiddleware] ¶
- class pyramid_blacksmith.binding.BlacksmithMiddlewareFactoryBuilder(settings: Mapping[str, str], metrics: PrometheusMetrics, prefix: str = 'client')¶
Parse the settings like:
blacksmith.client.middleware_factories = forward_header blacksmith.client.middleware_factory.forward_header = Authorization
- build() Iterator[AbstractMiddlewareFactoryBuilder] ¶
- class pyramid_blacksmith.binding.PyramidBlacksmith(request: Request, clients: dict[str, SyncClientFactory[Any]], middleware_factories: dict[str, list[AbstractMiddlewareFactoryBuilder]])¶
Type of the request.blacksmith property.
This can be used to create a
Protocol
of the pyramidRequest
in final application for typing purpose.Example:
from pyramid_blacksmith import PyramidBlacksmith class RequestProtocol(Protocol): blacksmith: PyramidBlacksmith def my_view(request: RequestProtocol): ...
- __getattr__(name: str) Callable[[str], SyncClient[Any]] ¶
Return the blacksmith client factory named in the configuration.
- pyramid_blacksmith.binding.blacksmith_binding_factory(config: Configurator) Callable[[Request], PyramidBlacksmith] ¶
- pyramid_blacksmith.binding.includeme(config: Configurator)¶
Expose the method consume by the Configurator while using:
config.include('pyramid_blacksmith')
This will inject the request property
request.blacksmith
like the pyramid view below:def my_view(request): api = request.blacksmith.client("api") ...