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.0.

Instalacao via pip (1.0.0)

Canal oficial (PyPI):

pip install tenant-rpa-sdk==1.0.0

Canal alternativo (wheel da GitHub Release):

pip install "https://github.com/<org>/<repo>/releases/download/tenant-rpa-sdk-v1.0.0/tenant_rpa_sdk-1.0.0-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.0.tar.gz (14.6 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.0-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tenant_rpa_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 14.6 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.0.tar.gz
Algorithm Hash digest
SHA256 0933f92b53d1ff41a25bfeeac4ca258534e713fef458d12740b9496041496a80
MD5 237d280568cdaf856778d508bddfb648
BLAKE2b-256 d7d2d283ca98762b0671a2b2c955249b4c995431e0f7d58ef1e96e6674739f8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tenant_rpa_sdk-1.0.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: tenant_rpa_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 18.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bba6f6dc1c73e6800dac7eb67c139ba7719932fcc946c8afc1071bcda733d0c1
MD5 8b0306d67e42a4a003b0b09f186c5e5f
BLAKE2b-256 d27ad7fd809c4f0652c8bfdcb21b1d6e1094e465382daf34d26843523e65077b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tenant_rpa_sdk-1.0.0-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