def __init__(self, urls: str, method: str = 'GET', headers: dict = {}, data: dict = None, json: dict = None, frequency: int = -1, count: int = 1): """ :param urls: URLs to fetch :param method: HTTP method (``GET``, ``POST``, ...) :param headers: HTTP headers field (defaults to an empty ``dict``) :param data: Form field (defaults to ``None``) Should be either ``None`` or a ``dict`` field :param json: JSON payload (defaults to ``None``) Should be either ``None`` or a ``dict`` field :param frequency: Sleep time between each call (defaults to -1, i.e. no sleep time) :param count: Number of requests to performs (defaults to 1, i.e. a single request) """ super().__init__(urls, method, headers, data, json, frequency, count) self.fields = FieldsMap( **{ 'urls': Field(urls, seqn=True, default=[]), 'method': Field(method, default=method), 'headers': Field(headers, default=headers), 'data': Field(data, default=data), 'json': Field(json, default=json), 'frequency': Field(frequency, default=frequency), 'count': Field(count, default=count) })
def __init__(self, name: str, macro_kwargs: dict = {}): """ :param name: Macro name. """ super().__init__(name) self.name = Field(name, default=name) self.params = FieldsMap( **dict([(name, Field(field)) for name, field in macro_kwargs.items()]))
def __init__(self, url: str = 'tcp://127.0.0.1:5555', codec: str = 'msgpack', **kwargs): """ :param url: ZMQ url (including protocol, address and port) :param codec: Encoder name (defaults to 'msgpack') """ self.args = FieldsMap(**{ 'url': Field(url, default='tcp://127.0.0.1:5555'), 'codec': Field(codec, default='msgpack'), })
def __init__(self, field, expr: str, clean: bool = True): """ :param field: Source field to cut :param expr: Regular expression """ super().__init__(field, expr, clean) self.field = Field(field) self.fields = FieldsMap(**{ 'expr': Field(expr), 'clean': Field(clean, default=True) })
def __init__(self, protocol: str = 'tcp', host: str = 'host', port: str = 'port'): """ :param protocol: Protocol to use, defaults to TCP :param host: Host IP to bind, default to localhost / 127.0.0.1 :param port: Host port to bind, default to 9999 """ self.fields = FieldsMap( **{ 'protocol': Field(protocol, default=protocol), 'host': Field(host, default='127.0.0.1'), 'port': Field(port, default=9999) })
def __init__(self, path: str = 'path', encoder: str = 'encoder', host: str = 'host', port: str|int = 'port'): """ :param path: Event's field name indicating on which path the event should be broadcasted :param encoder: Encoder name :param host: Websocket server host :param port: Websocket server port """ super().__init__(path, encoder, host, port) self.path = Field(path, default='/') self.fields = FieldsMap(**{ 'encoder': Field(encoder, default='json'), 'host': Field(host, default='127.0.0.1'), 'port': Field(port, default=8888) }) self.paths: dict[str, Any] = {}
def __init__(self, count: int = 1, showinfo: bool = False, frequency: float = 0.0, freqdelay: int = 1): """ :param count: Number of events to generate. :param showinfo: If set to `True`, add event ID and chunks information. Defaults to `False`. :param frequency: Amount of time to wait in seconds before generating a new event. Defaults to `0` (no wait). :param freqdelay: Amount of events to generate before applying `frequency`. """ super().__init__(count, showinfo, frequency) self.fields = FieldsMap( **{ 'count': Field(count, default=1, type=int), 'showinfo': Field(showinfo, default=False, type=bool), 'frequency': Field(frequency, default=0.0, type=(float, int)), 'freqdelay': Field(freqdelay, default=1, type=int) })
def __init__(self, host: str = 'localhost', port: int = 8080, rules: list = [], piperef: str = None): """ :param host: Server host; Defaults to ``localhost`` :param port: Server port; Defaults to ``8080`` :param rules: AIOHTTP routes rules; List of tuples as (method, path, pipeline); Mutually-exclusive with ``piperef`` :param piperef: Default pipeline to run; Mutually-exclusive with ``rules`` """ super().__init__(host, port, rules, piperef) # Base arguments self.fields = FieldsMap(**{ 'host': Field(host, default=host), 'port': Field(port, default=port) }) # Rules self.rules = rules # Default pipeline reference self.piperef = Field(piperef, default=piperef)
def __init__(self, **kwargs): self.fields = FieldsMap(**dict([(k, Field(v)) for k, v in kwargs.items()])) self.tags = Field('tags')