Signals

Signals for proxy app.

smarter.apps.proxy.signals.broker_ready = <django.dispatch.dispatcher.Signal object>

Sent when a Proxy broker is ready.

Arguments: broker.

smarter.apps.proxy.signals.proxy_request_completed = <django.dispatch.dispatcher.Signal object>

Sent when the provider has responded to a request that a Proxy forwarded, whatever its status.

For a stream, it is sent when the stream ends. Arguments: proxy, user_profile, method, path, status, usage (a Usage, or None) and elapsed (seconds).

smarter.apps.proxy.signals.proxy_request_failed = <django.dispatch.dispatcher.Signal object>

Sent when a Proxy refuses a request, or cannot reach the provider.

Arguments: proxy, user_profile, method, path, error (a ProxyError) and elapsed (seconds).

Receiver functions for proxy signals.

smarter.apps.proxy.receivers.invalidate_proxy_caches(sender, instance, **kwargs)[source]

Invalidate the owner’s cached Proxy lists, which the web console’s list view uses.

A failure is logged as a warning, not raised.

Parameters:
  • sender – The model class.

  • instance (Proxy) – The Proxy that was saved or deleted.

smarter.apps.proxy.receivers.log_broker_ready(sender, broker, **kwargs)[source]

Log when the broker is ready.

Parameters:
  • sender – The signal’s sender.

  • broker – The Proxy broker.

smarter.apps.proxy.receivers.log_proxy_request_completed(sender, proxy, user_profile, method, path, status, usage, elapsed, **kwargs)[source]

Log each request that a Proxy forwarded.

Parameters:
  • sender – The signal’s sender.

  • proxy – The Proxy.

  • user_profile – The caller’s user profile.

  • method – The HTTP method.

  • path – The provider API path.

  • status – The provider’s HTTP status code.

  • usage – The token usage that the response reported.

  • elapsed – The seconds that the forward took.

smarter.apps.proxy.receivers.log_proxy_request_failed(sender, proxy, user_profile, method, path, error, elapsed, **kwargs)[source]

Log each request that a Proxy refused, or could not forward.

Parameters:
  • sender – The signal’s sender.

  • proxy – The Proxy.

  • user_profile – The caller’s user profile.

  • method – The HTTP method.

  • path – The provider API path.

  • error – The error.

  • elapsed – The seconds until the failure.