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.2.2.tar.gz (36.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.2.2-py3-none-any.whl (42.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for yellowstone_fumarole_client-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c15e80c5da342f06f23502d4aff1c263d97ee1708e231513e0166fce2dd15acb
MD5 51d001c64b0ca0dd5a262584516ea442
BLAKE2b-256 07c9f4057b8d8e1f56a74ffed79fd89563ef98e501cdbfe867f130aa9196c228

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yellowstone_fumarole_client-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 05888dbafcb50a2af69c538adc385463d9d402b93733cba55d78ba3368891679
MD5 08978cbeb685dc52a29097cee8d786c0
BLAKE2b-256 68a08fa3c20943d029387dfd12b7de1f89f68020c6bac9db02e56c2327fdef2f

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