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.1.tar.gz (37.2 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.1-py3-none-any.whl (43.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yellowstone_fumarole_client-0.3.1.tar.gz
  • Upload date:
  • Size: 37.2 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.3.1.tar.gz
Algorithm Hash digest
SHA256 efa10a3b2e4003ea7a64e66045b21ed5e36dd47c37428fc80f1b7a49220e66b4
MD5 b0f676f8b8acc2dcad4747b36a3ace66
BLAKE2b-256 6e355af8a9c0ec93eccf156937568304c6034950477421d0c32163aa1e06ef6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yellowstone_fumarole_client-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e47322360114b5737e076993a38e709656cb9be1a6b7b21b44ce85ab86c1f99
MD5 8960f2f79acf7f3e3b6cd0e43a677118
BLAKE2b-256 86f1ea54202dfad2049a7de6305c28e4e15a84aa80a91215ef41e558d3c4deb2

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