Attention

This is the documentation for HARP Proxy, actually published as an early preview. Both the software and documentation are a work in progress, and although we already use it on various production servers, they may contain inaccuracies, typographical errors, huge mistakes and empty pages. We work hard to eradicate all mistakes and implement stuff, but it is a long and tedious process. We appreciate your patience and understanding. Of course, any help will be greatly appreciated.

Config (harp.config)

The Config (harp.config) module provides tools to configure Applications.

Applications are standard python packages that contains specific definitions to be able to register services and configure themselves. Every feature of Harp is built as an application, and you will want to write applications if you want to extend harp’s functionality for specific needs.

Contents

class Application[source]

Bases: object

Base class for writing harp applications, which are basically python packages with auto-registration superpowers.

TODO: - use settings instead of settings_type, with type annotation ? - namespace instead of settings namespace ? autodetect from settings ?

__init__(settings=None, /)[source]
static defaults(settings=None)[source]
Parameters:

settings (dict | None)

Return type:

dict

register_events(dispatcher)[source]
Parameters:

dispatcher (IAsyncEventDispatcher)

register_services(container)[source]
Parameters:

container (Container)

classmethod supports(settings)[source]
Parameters:

settings (dict)

Return type:

bool

validate(*, secure=False)[source]
name = None
on_bind = None

Placeholder for factory bind event, happening before the container is built. If set, it will be attached to the factory dispatcher automatically.

on_bound = None

Placeholder for factory bound event, happening after the container is built. If set, it will be attached to the factory dispatcher automatically.

on_build = None

Placeholder for factory build event, happening after the kernel is built. If set, it will be attached to the factory dispatcher automatically.

settings_namespace = None
settings_type = None
class BaseSetting[source]

Bases: object

BaseSetting()

__init__()
Return type:

None

to_dict(*, secure=True)[source]
class Config[source]

Bases: object

__init__(settings=None, /, applications=None)[source]
add_application(name, /, *, debug=False)[source]
add_defaults()[source]
classmethod deserialize(settings)[source]
get_application_type(name)[source]
Parameters:

name (str)

Return type:

Type[Application]

read_env(options, /)[source]

Parses sys.argv-like arguments.

Parameters:
  • args

  • files – list of filenames to load in order. Will happen after defaults env and files.

  • options (CommonServerOptions)

Returns:

argparse.Namespace

register_events(dispatcher)[source]
Parameters:

dispatcher (IAsyncEventDispatcher)

register_services(container)[source]
Parameters:

container (Container)

remove_application(name)[source]
reset()[source]
serialize()[source]
set(key, value)[source]
validate(*, allow_extraneous_settings=False, secure=False)[source]
DEFAULT_APPLICATIONS = ['http_client', 'proxy', 'dashboard', 'sqlalchemy_storage', 'telemetry', 'janitor', 'harp_apps.contrib.sentry']
property applications
property settings
class Definition[source]

Bases: Generic[T]

Definition(*, path: str, name: str, args: Optional[Tuple] = None, kwargs: Optional[Mapping] = None)

__init__(*, path, name, args=None, kwargs=None)
Parameters:
Return type:

None

build(*args, **kwargs)[source]
Return type:

T

to_dict(*, secure=True)
validate()[source]
args: Tuple | None = None
property factory
kwargs: Mapping | None = None
property module
name: str
path: str
property spec
class DisableableBaseSettings[source]

Bases: BaseSetting

DisableableBaseSettings(**kwargs)

__init__(enabled=True)
Parameters:

enabled (bool | None)

Return type:

None

static __new__(cls, **kwargs)[source]
enabled: bool | None = True
class DisabledSettings[source]

Bases: BaseSetting

DisabledSettings(*args, **kwargs)

__init__(*args, **kwargs)[source]
enabled: bool = False
class FromFileSetting[source]

Bases: BaseSetting

FromFileSetting(from_file: str)

__init__(from_file)
Parameters:

from_file (str)

Return type:

None

exists()[source]
classmethod may_override(instance, attr)[source]
open(*args, **kwargs)[source]
from_file: str
Lazy(path_or_factory, *args, _default=None, **kwargs)[source]
Return type:

Definition[type]

asdict(obj, /, *, secure=True)[source]
settings_dataclass(cls=None, /, *, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False)

Add dunder methods based on the fields defined in the class.

Examines PEP 526 __annotations__ to determine fields.

If init is true, an __init__() method is added to the class. If repr is true, a __repr__() method is added. If order is true, rich comparison dunder methods are added. If unsafe_hash is true, a __hash__() method is added. If frozen is true, fields may not be assigned to after instance creation. If match_args is true, the __match_args__ tuple is added. If kw_only is true, then by default all fields are keyword-only. If slots is true, a new class with a __slots__ attribute is returned.

Submodules