pyramid_blacksmith.binding#

class pyramid_blacksmith.binding.SettingsBuilder(settings: Mapping[str, str], metrics: blacksmith.domain.model.middleware.prometheus.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() blacksmith.domain.model.middleware.prometheus.PrometheusMetrics#

Return the first PrometheusMetrics object build from the settings passed.

class pyramid_blacksmith.binding.BlacksmithClientSettingsBuilder(settings: Mapping[str, str], metrics: blacksmith.domain.model.middleware.prometheus.PrometheusMetrics, prefix: str = 'client')#
build() blacksmith.service._sync.client.SyncClientFactory[Any]#
build_sd_static() blacksmith.sd._sync.adapters.static.SyncStaticDiscovery#
build_sd_consul() blacksmith.sd._sync.adapters.consul.SyncConsulDiscovery#
build_sd_router() blacksmith.sd._sync.adapters.router.SyncRouterDiscovery#
build_sd_strategy() blacksmith.sd._sync.base.SyncAbstractServiceDiscovery#
get_timeout() blacksmith.domain.model.http.HTTPTimeout#
get_proxies() Optional[Union[URL, str, Proxy, Dict[Union[URL, str], Union[None, URL, str, Proxy]]]]#
get_verify_certificate() bool#
build_transport() Optional[blacksmith.service._sync.base.SyncAbstractTransport]#
build_collection_parser() Type[blacksmith.domain.model.params.CollectionParser]#
build_error_parser() blacksmith.domain.error.AbstractErrorParser[Any]#
build_middlewares(metrics: blacksmith.domain.model.middleware.prometheus.PrometheusMetrics) Iterator[blacksmith.middleware._sync.base.SyncHTTPMiddleware]#
class pyramid_blacksmith.binding.BlacksmithMiddlewareFactoryBuilder(settings: Mapping[str, str], metrics: blacksmith.domain.model.middleware.prometheus.PrometheusMetrics, prefix: str = 'client')#

Parse the settings like:

blacksmith.client.middleware_factories =
    forward_header

blacksmith.client.middleware_factory.forward_header =
    Authorization
build() Iterator[pyramid_blacksmith.middleware_factory.AbstractMiddlewareFactoryBuilder]#
class pyramid_blacksmith.binding.PyramidBlacksmith(request: pyramid.request.Request, clients: Dict[str, blacksmith.service._sync.client.SyncClientFactory[Any]], middleware_factories: Dict[str, List[pyramid_blacksmith.middleware_factory.AbstractMiddlewareFactoryBuilder]])#

Type of the request.blacksmith property.

This can be used to create a Protocol of the pyramid Request 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], blacksmith.service._sync.client.SyncClient[Any]]#

Return the blacksmith client factory named in the configuration.

pyramid_blacksmith.binding.blacksmith_binding_factory(config: pyramid.config.Configurator) Callable[[pyramid.request.Request], pyramid_blacksmith.binding.PyramidBlacksmith]#
pyramid_blacksmith.binding.includeme(config: pyramid.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")
    ...