Skip to main content

Yellowstone Fumarole Python Client

Project description

Fumarole Python SDK

This module contains Fumarole SDK for python programming language.

Configuration

endpoint: <"https://fumarole.endpoint.rpcpool.com">
x-token: <YOUR X-TOKEN secret here>

Manage consumer group

Refer to fume CLI to manage your consumer groups.

Examples

from typing import Optional
import uuid
import asyncio
import logging
from os import environ
from collections import defaultdict
from yellowstone_fumarole_client.config import FumaroleConfig
from yellowstone_fumarole_client import FumaroleClient
from yellowstone_fumarole_proto.fumarole_v2_pb2 import CreateConsumerGroupRequest
from yellowstone_fumarole_proto.geyser_pb2 import (
    SubscribeRequest,
    SubscribeRequestFilterAccounts,
    SubscribeRequestFilterTransactions,
    SubscribeRequestFilterBlocksMeta,
    SubscribeRequestFilterEntry,
    SubscribeRequestFilterSlots,
)
from yellowstone_fumarole_proto.geyser_pb2 import (
    SubscribeUpdate,
    SubscribeUpdateTransaction,
    SubscribeUpdateBlockMeta,
    SubscribeUpdateAccount,
    SubscribeUpdateEntry,
    SubscribeUpdateSlot,
)

async def dragonsmouth_like_session(fumarole_config):
    with open("~/.fumarole/config.yaml") as f:
        fumarole_config = FumaroleConfig.from_yaml(f)
    
    client: FumaroleClient = await FumaroleClient.connect(fumarole_config)
    await client.delete_all_consumer_groups()

    # --- This is optional ---
    resp = await client.create_consumer_group(
        CreateConsumerGroupRequest(
            consumer_group_name="test",
        )
    )
    assert resp.consumer_group_id, "Failed to create consumer group"
    # --- END OF OPTIONAL BLOCK ---

    session = await client.dragonsmouth_subscribe(
        consumer_group_name="test",
        request=SubscribeRequest(
            accounts={"fumarole": SubscribeRequestFilterAccounts()},
            transactions={"fumarole": SubscribeRequestFilterTransactions()},
            blocks_meta={"fumarole": SubscribeRequestFilterBlocksMeta()},
            entry={"fumarole": SubscribeRequestFilterEntry()},
            slots={"fumarole": SubscribeRequestFilterSlots()},
        ),
    )
    async with session:
        dragonsmouth_like_source = session.source
        # result: SubscribeUpdate
        async for result in dragonsmouth_like_source:
            if result.HasField("block_meta"):
                block_meta: SubscribeUpdateBlockMeta = result.block_meta
            elif result.HasField("transaction"):
                tx: SubscribeUpdateTransaction = result.transaction
            elif result.HasField("account"):
                account: SubscribeUpdateAccount = result.account
            elif result.HasField("entry"):
                entry: SubscribeUpdateEntry = result.entry
            elif result.HasField("slot"):
                result: SubscribeUpdateSlot = result.slot

    # OUTSIDE THE SCOPE, YOU SHOULD NEVER USE `session` again.

At any point you can get a rough estimate if you are progression through the slot using DragonsmouthAdapterSession.stats() call:

async with session:
    stats: FumaroleSubscribeStats = session.stats()
    print(f"{stats.log_committed_offset}, {stats.log_committable_offset}, {stats.max_slot_seen}")

log_committed_offset : what have been ACK so for to fumarole remote service. log_committable_offset : what can be ACK to next commit call. max_slot_seen : maximum slot seen in the inner fumarole client state -- not yet processed by your code.

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

yellowstone_fumarole_client-0.3.3.tar.gz (37.4 kB view details)

Uploaded Source

Built Distribution

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

yellowstone_fumarole_client-0.3.3-py3-none-any.whl (43.4 kB view details)

Uploaded Python 3

File details

Details for the file yellowstone_fumarole_client-0.3.3.tar.gz.

File metadata

  • Download URL: yellowstone_fumarole_client-0.3.3.tar.gz
  • Upload date:
  • Size: 37.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.10.12 Linux/6.8.0-90-generic

File hashes

Hashes for yellowstone_fumarole_client-0.3.3.tar.gz
Algorithm Hash digest
SHA256 0d417b9d54702944749c550cdd683db2dcadab836135cbdd33fd38c1209bf88b
MD5 ba3e1bb725021473ada417b9308be88a
BLAKE2b-256 e612017f4f6fef9af2975577ee5b15e7e271282bd4d810f3711bd82a9ac8627c

See more details on using hashes here.

File details

Details for the file yellowstone_fumarole_client-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for yellowstone_fumarole_client-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 00fd84810aaf17b8dab08eb33747cacdced87550bcd2b660df856ba7e0cc97dc
MD5 3daa525b017574033c1e3bbdf28217bf
BLAKE2b-256 52369ff6eb3364b9b331f42f5c5eb3016899daf5fb52d78c42d0f1d41ed7dca1

See more details on using hashes here.

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