Skip to main content

Mini Apollo

A lightweight Python SDK for Apollo Config.

Installation

pip install mini-apollo

Quick Start

from mini_apollo import ApolloClient, ApolloConfig

# Basic client setup
client = ApolloClient(
    server_url="http://your-apollo-server:8080",
    app_id="your-app-id",
    secret="your-secret"
)

# Fetch config once
config = client.fetch_config()
print(config.get("db.host"))

# Auto-refreshing config
config = ApolloConfig(
    client=client,
    auto_refresh=True,
    refresh_interval=30
)
print(config["http.timeout"])

Async Support

import asyncio
from mini_apollo import ApolloClient

async def main():
    client = ApolloClient(
        server_url="http://your-apollo-server:8080",
        app_id="your-app-id"
    )
    
    config = await client.async_fetch_config()
    print(config.get("db.host"))

asyncio.run(main())

Configuration Options

from mini_apollo import ApolloClient, ApolloConfig

client = ApolloClient(
    server_url="http://your-apollo-server:8080",
    app_id="your-app-id"
)

# Specify cluster and namespace
config = client.fetch_config(
    cluster="production",
    namespace="database"
)

# Background refresh
config = ApolloConfig(
    client=client,
    cluster="production",
    namespace="database",
    auto_refresh=True,
    refresh_interval=60
)

Pydantic Integration

from functools import cached_property

from pydantic import Field, computed_field
from pydantic_settings import BaseSettings, SettingsConfigDict

from mini_apollo import ApolloClient, ApolloConfig


class AppSettings(BaseSettings):
    apollo_server_url: str = Field(..., description="Apollo Server URL")
    apollo_app_id: str = Field(..., description="Apollo App ID")
    apollo_cluster: str = Field("default")
    apollo_namespace: str = Field("application")

    model_config = SettingsConfigDict(env_file=".env")

    @computed_field
    @cached_property
    def apollo_client(self) -> ApolloClient:
        return ApolloClient(
            server_url=self.apollo_server_url,
            app_id=self.apollo_app_id
        )

    @computed_field
    @cached_property
    def apollo_config(self) -> ApolloConfig:
        return ApolloConfig(
            client=self.apollo_client,
            cluster=self.apollo_cluster,
            namespace=self.apollo_namespace,
            auto_refresh=True,
            refresh_interval=30
        )

    @computed_field
    @property
    def db_host(self) -> str:
        return self.apollo_config["db.host"]


# Usage
settings = AppSettings()
print(f"Database host: {settings.db_host}")

Metadata

Release files for mini-apollo 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mini-apollo 0.1.2
File Size Uploaded
mini_apollo-0.1.2.tar.gz 5.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mini-apollo 0.1.2
File Interpreter ABI Platform
mini_apollo-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 9.9 kB

Release files / mini_apollo-0.1.2.tar.gz

Download URL mini_apollo-0.1.2.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7813e3f6ca5f431dd6547d4865cc7c38ce5dad8cd2ff59e53f95ac537549b347
BLAKE2b-256 checksum
How to use checksums
ec15284c2e5ab294555215ca5eeda42c3992ae385018ca237cb1a07d751a1f07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release files / mini_apollo-0.1.2-py3-none-any.whl

Download URL mini_apollo-0.1.2-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
491093e7fda32754ff204430c045e7af6cd7fd8036ce0c222efaebbcd88138c9
BLAKE2b-256 checksum
How to use checksums
90ec4c21dcbda72b15fc5fa51ca57d27f5b4ed923d0c35286eed8633c20738a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.23

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page