firehose

package module
v0.0.0-...-89f5f27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: GPL-3.0 Imports: 9 Imported by: 1

Documentation

Overview

Package firehose provides a client for consuming the Bluesky firehose API stream

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Firehose

type Firehose struct {
	// contains filtered or unexported fields
}

Firehose represents a client connection to the Bluesky firehose

func New

func New(wsURL string) (*Firehose, error)

New creates a new Firehose client connected to the specified websocket URL

func (*Firehose) Authenticate

func (f *Firehose) Authenticate(email, password string) error

Authenticate logs into Bluesky using email/password and stores the access token

func (*Firehose) Close

func (f *Firehose) Close() error

Close terminates the firehose connection

func (*Firehose) ConsumeJetstream

func (f *Firehose) ConsumeJetstream(ctx context.Context, handler func(JetstreamPost) error, errCallback ...func(error)) error

ConsumeJetstream consumes the Bluesky Jetstream API stream with the provided handler

func (*Firehose) FetchPost

func (f *Firehose) FetchPost(uri string) (string, error)

FetchPost retrieves the text content of a post by its URI

func (*Firehose) OnPost

func (f *Firehose) OnPost(ctx context.Context, handler func(string) error) error

OnPost registers a callback function to handle new posts from the firehose

func (*Firehose) Subscribe

func (f *Firehose) Subscribe(ctx context.Context, handler FirehoseHandler) error

Subscribe starts consuming the firehose stream with the provided handler

type FirehoseHandler

type FirehoseHandler interface {
	HandleEvent(*atproto.SyncSubscribeRepos_Commit) error
}

FirehoseHandler defines the interface for handling firehose events

type JetstreamPost

type JetstreamPost struct {
	DID    string `json:"did"`
	Time   int64  `json:"time_us"`
	Type   string `json:"type"`
	Kind   string `json:"kind"`
	Commit struct {
		Record struct {
			Text string `json:"text"`
		} `json:"record"`
	} `json:"commit"`
}

type Post

type Post struct {
	Thread struct {
		Post struct {
			Record struct {
				Text string `json:"text"`
			}
		}
	}
}

Post represents the structure of a Bluesky post response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL