Skip to main content

SDK de logging resiliente para automacoes Python com fallback local

Project description

tenant-rpa-sdk

SDK Python para logging resiliente e modulos de execucao/infra para automacoes.

Versao de referencia desta documentacao: 1.0.1.

Instalacao via pip (1.0.1)

Canal oficial (PyPI):

pip install tenant-rpa-sdk==1.0.1

Canal alternativo (wheel da GitHub Release):

pip install "https://github.com/<org>/<repo>/releases/download/tenant-rpa-sdk-v1.0.1/tenant_rpa_sdk-1.0.1-py3-none-any.whl"

Doc dedicada de pip: docs/pip.md.

Resumo executivo dos modulos

1) Logger

Modulo: tenant_rpa_sdk.logger (TenantBackendLogger) O que faz: logging resiliente com dedupe por idempotency_key e fallback JSONL. Instanciamento rapido: logger = TenantBackendLogger(project_name="demo", source="automation.demo")

2) DB connection

Modulo: tenant_rpa_sdk.db (TenantDatabaseConnect) O que faz: conexao Postgres (connect, connection, close). Instanciamento rapido: db = TenantDatabaseConnect(load_sdk_config(env=env).db)

3) Execution manager

Modulo: tenant_rpa_sdk.execution (TenantExecutionManage) O que faz: ciclo de execucao (QUEUED -> RUNNING -> terminal) e heartbeat. Instanciamento rapido: exec_mgr = TenantExecutionManage(db_client=db)

4) Execution context

Modulo: tenant_rpa_sdk.execution (TenantExecutionContext) O que faz: contexto tipado da execucao (ids, host, container, external job). Instanciamento rapido: ctx = TenantExecutionContext(execution_id=1, project_id=1, schedule_id=None, hostname="host", container_id=None, external_job_id=None)

5) Project query

Modulo: tenant_rpa_sdk.projects (TenantProjectQuery) O que faz: consulta projeto por nome. Instanciamento rapido: project_q = TenantProjectQuery(db_client=db)

6) Infra status sync

Modulo: tenant_rpa_sdk.infrastructure (TenantInfraStatusSync) O que faz: lista alvos de infraestrutura e faz upsert de status/capacidade. Instanciamento rapido: infra = TenantInfraStatusSync(db_client=db)

7) Slack notify

Modulo: tenant_rpa_sdk.notify (TenantSlackNotify) O que faz: envia alerta Slack em texto e bloco. Instanciamento rapido: slack = TenantSlackNotify(channel_id="C123", token="xoxb-***")

8) DB utils (interno-chave)

Modulo: tenant_rpa_sdk.db_utils O que faz: helpers de query (execute, fetch_one, fetch_all) e operacoes de dominio DB. Instanciamento rapido: rows = fetch_all(db, "SELECT 1 AS ok", as_dict=True)

9) RPA logs sink (interno-chave)

Modulo: tenant_rpa_sdk.sinks.rpa_logs_sink (RPALogsSink) O que faz: escrita resiliente no DB com retry curto. Instanciamento rapido: sink = RPALogsSink(db)

10) Fallback sink (interno-chave)

Modulo: tenant_rpa_sdk.sinks.fallback_jsonl (FallbackJSONLSink) O que faz: pendencias locais em JSONL com lock de arquivo. Instanciamento rapido: fallback = FallbackJSONLSink("/tmp/pending.jsonl")

Quickstart minimo

from tenant_rpa_sdk import (
    TenantBackendLogger,
    TenantDatabaseConnect,
    TenantExecutionManage,
    TenantProjectQuery,
    TenantInfraStatusSync,
    TenantSlackNotify,
)
from tenant_rpa_sdk.config import load_sdk_config

env = {
    "APP_DB_PRIMARY": "postgres,db.example.local,5432,ops_data,svc_user,***",
    "APP_LOG_TABLE": "event_logs",
    "APP_SLACK_CHANNEL_ID": "C123",
    "APP_SLACK_BOT_TOKEN": "xoxb-***",
}

config = load_sdk_config(env=env, flush_on_start=False)
db = TenantDatabaseConnect(config.db, config.logs_table)

logger = TenantBackendLogger(project_name="demo", source="automation.demo", env=env)
project_q = TenantProjectQuery(db_client=db)
infra = TenantInfraStatusSync(db_client=db)
exec_mgr = TenantExecutionManage(db_client=db)
slack = TenantSlackNotify(channel_id=env["APP_SLACK_CHANNEL_ID"], token=env["APP_SLACK_BOT_TOKEN"])

API publica

  • TenantBackendLogger
  • TenantDatabaseConnect
  • TenantExecutionContext
  • TenantExecutionManage
  • TenantProjectQuery
  • TenantInfraStatusSync
  • TenantSlackNotify

Aliases temporarios de compatibilidade:

  • ExecutionService
  • ExecutionContext
  • Slack

Testes

Unitarios:

pytest tests/unit

Integracao (opt-in):

export TENANT_RPA_SDK_INTEGRATION=true
pytest tests/integration

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tenant_rpa_sdk-1.0.1.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tenant_rpa_sdk-1.0.1-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file tenant_rpa_sdk-1.0.1.tar.gz.

File metadata

  • Download URL: tenant_rpa_sdk-1.0.1.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tenant_rpa_sdk-1.0.1.tar.gz
Algorithm Hash digest
SHA256 33495e0e7952e08f9e109199fb4431d856ef446676a1d7d79fc40719acc26270
MD5 c9d54aaef14359d98275376720b3f4b4
BLAKE2b-256 1d4910ab469f6295d71c61741eee0becf0b20f267887a0ecb6df9396cb2d1fd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for tenant_rpa_sdk-1.0.1.tar.gz:

Publisher: python-release.yml on tech-ops-ai/tenant-rpa-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tenant_rpa_sdk-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: tenant_rpa_sdk-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tenant_rpa_sdk-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca177a8d6ef0dc36bc4f8487773151dafd953fdfed0a19ce78f2c5922a9c376e
MD5 5f91388abd7a1d7f47a1ed42b8630a24
BLAKE2b-256 77b4d8eed4d46deb9298b51d508c5547f4cb25efdad6d686f028cfad1f732549

See more details on using hashes here.

Provenance

The following attestation bundles were made for tenant_rpa_sdk-1.0.1-py3-none-any.whl:

Publisher: python-release.yml on tech-ops-ai/tenant-rpa-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page