{"id":20068411,"url":"https://github.com/guiabolso/events-protocol-python","last_synced_at":"2026-03-10T19:30:53.529Z","repository":{"id":40387150,"uuid":"233128668","full_name":"GuiaBolso/events-protocol-python","owner":"GuiaBolso","description":"Library to be a Client and Server using event protocol","archived":false,"fork":false,"pushed_at":"2022-12-26T21:38:19.000Z","size":223,"stargazers_count":4,"open_issues_count":4,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-13T06:27:49.369Z","etag":null,"topics":["events-protocol","guiabolso","python","python3"],"latest_commit_sha":null,"homepage":"https://events-protocol.readthedocs.io/en/stable/index.html","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GuiaBolso.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-10T20:53:57.000Z","updated_at":"2023-04-30T14:44:45.000Z","dependencies_parsed_at":"2023-01-31T01:50:18.548Z","dependency_job_id":null,"html_url":"https://github.com/GuiaBolso/events-protocol-python","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuiaBolso%2Fevents-protocol-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuiaBolso%2Fevents-protocol-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuiaBolso%2Fevents-protocol-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GuiaBolso%2Fevents-protocol-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GuiaBolso","download_url":"https://codeload.github.com/GuiaBolso/events-protocol-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224461753,"owners_count":17315116,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["events-protocol","guiabolso","python","python3"],"created_at":"2024-11-13T14:06:50.759Z","updated_at":"2026-03-10T19:30:53.478Z","avatar_url":"https://github.com/GuiaBolso.png","language":"Python","readme":"\u003ch1 align=\"center\"\u003eevents-protocol\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://badge.fury.io/py/events-protocol\"\u003e\u003cimg alt=\"PyPI version\" src=\"https://badge.fury.io/py/events-protocol.svg\"\u003e\u003c/a\u003e\n    \u003ca href='https://events-protocol.readthedocs.io/en/latest/?badge=latest'\u003e\u003cimg src='https://readthedocs.org/projects/events-protocol/badge/?version=latest' alt='Documentation Status' /\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/GuiaBolso/events-protocol-python/actions\"\u003e\u003cimg alt=\"Actions Status\" src=\"https://github.com/GuiaBolso/events-protocol-python/workflows/Black%20Check%20and%20Tests/badge.svg?branch=master\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/GuiaBolso/events-protocol-python/blob/master/LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/psf/black\"\u003e\u003cimg alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://pypi.org/project/events-protocol/\"\u003e\u003cimg alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/events-protocol.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n### Configurando para desenvolvimento local\nPara fazer alterações na biblioteca localmente e passar pelos checks de formatação é necessário executar os seguintes passos:\n\nPrimeiramente, deve-se instalar o [Homebrew](https://brew.sh/index_pt-br).\n\nDepois, podemos instalar o pipenv e o pyenv.\n```\npip install pipenv\nbrew install pyenv\n```\nEntão, deve-se buildar a biblioteca pelo Makefile, e depois de configurado o ambiente, deve-se garantir o funcionamento do pre-commit\n```\nmake dev\npre-commit install\n```\nCom essa configuração aplicada, ao commitar a lib Black será acionada automaticamente para fazer o linting do código.\n\nCaso o código falhe na formatação, será emitido um status \"Failed\", e a biblioteca é acionada para reformatar.\n\nEntão, basta só commitar novamente para registrar as mudanças, dessa vez com a formatação correta.\n### Como usar\n#### Client\n\nAs informações essenciais para enviar o evento são: *url*, *name*, *version* e *payload*.\n\nApenas com estas informações já é possivel enviar um evento.\n\n```pyt\nfrom events_protocol.client import EventClient\n\n# Instancia o client\nclient = EventClient(url=\"http://example.com/events/\")\n\n# Exemplo passando apenas as informações essenciais\nresponse = client.send_event(\n\tname=\"event:example\",\n\tversion=1,\n\tpayload={\n\t\t\"example\": \"example\"\n\t},\n)\n\n# Exemplo passando todas as informações\nresponse = client.send_event(\n\tname=\"event:example\",\n\tversion=1,\n\tid=\"9230c47c-3bcf-11ea-b77f-2e728ce88125\",\n\tflow_id=\"a47830ca-3bcf-11ea-a232-2e728ce88125\",\n\tpayload={\n\t\t\"example\": \"example\"\n\t},\n\tidentity={\n\t\t\"userId\": \"USER_ID\",\n\t},\n\tmetadata={\n\t\t\"date\": \"00-00-0000\",\n\t},\n\ttimeout=1000,\n)\n```\n\n#### Server\n\nUm server é composto por *handler*, *register* e *EventSchema*.\n\nAbaixo se encontra um exemplo de utilização. \n\n\n```pyt\nfrom events_protocol.server.handler.event_handler_registry import EventRegister\nfrom events_protocol.core.builder import EventBuilder, Event\nfrom events_protocol.core.model.base import CamelPydanticMixin\nfrom events_protocol.core.model.event import Event, ResponseEvent\nfrom events_protocol.server.handler.event_handler import EventHandler\nfrom events_protocol.server.parser.event_processor import EventProcessor\n\n\nclass MyEventSchema(CamelPydanticMixin):\n    example: str\n\n\nclass MyHandler(EventHandler):\n    _SCHEMA = MyEventSchema\n\n    @classmethod\n    def handle(cls, event: Event) -\u003e ResponseEvent:\n        payload = cls.parse_event(event)\n        response = {\"MyEventPayload\": payload.example}\n        return EventBuilder.response_for(event, response)\n\n\nclass MyEventRegister(EventRegister):\n    event_name = \"get:event:example\"\n    event_version = 1\n    event_handler = MyHandler\n\n\nMyEventRegister.register_event()\n\nevent_input = Event(\n    name=\"get:event:example\",\n    version=1,\n    id=\"9230c47c-3bcf-11ea-b77f-2e728ce88125\",\n    flow_id=\"a47830ca-3bcf-11ea-a232-2e728ce88125\",\n    payload={\"example\": \"example\"},\n    identity={\"userId\": \"USER_ID\",},\n    metadata={\"date\": \"00-00-0000\",},\n)\ninput_body = event_input.to_json()\n\n## Apos todos eventos registrados, registre uma rota \"/events\" no seu framework web de preferência e processe o body utilizando o seguinte comando\nresponse = EventProcessor.process_event(input_body)\n\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguiabolso%2Fevents-protocol-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguiabolso%2Fevents-protocol-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguiabolso%2Fevents-protocol-python/lists"}