firehose

package
v0.0.0-...-3141384 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PostFromCommitEvent

func PostFromCommitEvent(evt CommitEvent) (*post.Post, error)

PostFromCommitEvent converts a CommitEvent to a Post

func SubscribeToFirehose deprecated

func SubscribeToFirehose(ctx context.Context, auth AuthProvider, callbacks *FirehoseCallbacks) error

Deprecated: Use Firehose.Subscribe instead

Types

type AuthProvider

type AuthProvider interface {
	GetAccessToken() string
	GetFirehoseURL() string
	GetTimeout() time.Duration
}

AuthProvider defines the minimal interface needed for firehose authentication

type CommitEvent

type CommitEvent struct {
	Repo string          // repository DID
	Time string          // timestamp
	Ops  []RepoOperation // operations performed
}

CommitEvent represents a commit to a repository

type EnhancedFirehose

type EnhancedFirehose struct {
	*Firehose
}

EnhancedFirehose extends the base Firehose with additional functionality

func NewEnhancedFirehose

func NewEnhancedFirehose(auth AuthProvider) *EnhancedFirehose

NewEnhancedFirehose creates a new EnhancedFirehose instance

func (*EnhancedFirehose) Subscribe

func (f *EnhancedFirehose) Subscribe(ctx context.Context, callbacks *EnhancedFirehoseCallbacks) error

Subscribe subscribes to the Bluesky firehose with enhanced functionality

type EnhancedFirehoseCallbacks

type EnhancedFirehoseCallbacks struct {
	*FirehoseCallbacks
	Handlers          []RawOperationHandler
	PostHandlers      []PostHandlerWithFilter
	HandleHandlers    []HandleHandlerWithFilter
	InfoHandlers      []InfoHandlerWithFilter
	MigrateHandlers   []MigrateHandlerWithFilter
	TombstoneHandlers []TombstoneHandlerWithFilter
	FollowHandlers    []interaction.FollowHandlerWithFilter
	LikeHandlers      []interaction.LikeHandlerWithFilter
	RepostHandlers    []interaction.RepostHandlerWithFilter
	CommentHandlers   []interaction.CommentHandlerWithFilter
}

EnhancedFirehoseCallbacks contains all the callback handlers

type Firehose

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

Firehose manages the connection to the Bluesky firehose

func NewFirehose

func NewFirehose(auth AuthProvider) *Firehose

NewFirehose creates a new Firehose instance

func (*Firehose) Close

func (f *Firehose) Close() error

Close closes the firehose connection

func (*Firehose) Subscribe

func (f *Firehose) Subscribe(ctx context.Context, callbacks *FirehoseCallbacks) error

Subscribe subscribes to the Bluesky firehose

type FirehoseCallbacks

type FirehoseCallbacks struct {
	// OnCommit is called when a repository commit occurs
	OnCommit func(evt *CommitEvent) error

	// OnHandle is called when a handle change occurs
	OnHandle func(evt *HandleEvent) error

	// OnInfo is called when repository information is received
	OnInfo func(evt *InfoEvent) error

	// OnMigrate is called when a repository migration occurs
	OnMigrate func(evt *MigrateEvent) error

	// OnTombstone is called when a repository is tombstoned
	OnTombstone func(evt *TombstoneEvent) error
}

FirehoseCallbacks defines callbacks for different firehose events

type FirehoseHandler

type FirehoseHandler interface {
	HandleRawOperation(op *RepoOperation) error
}

FirehoseHandler represents a generic handler for firehose events

type HandleEvent

type HandleEvent struct {
	Did    string // DID of the account
	Handle string // new handle
}

HandleEvent represents a handle change event

type HandleFilter

type HandleFilter func(*HandleEvent) bool

HandleFilter is a function that filters handle events

type HandleHandlerWithFilter

type HandleHandlerWithFilter struct {
	Handler func(*HandleEvent) error
	Filters []HandleFilter
}

HandleHandlerWithFilter combines a handle handler with its filters

type InfoEvent

type InfoEvent struct {
	Name    string // name of the event
	Message string // info message, may be empty
}

InfoEvent represents repository information

type InfoFilter

type InfoFilter func(*InfoEvent) bool

InfoFilter is a function that filters info events

type InfoHandlerWithFilter

type InfoHandlerWithFilter struct {
	Handler func(*InfoEvent) error
	Filters []InfoFilter
}

InfoHandlerWithFilter combines an info handler with its filters

type MigrateEvent

type MigrateEvent struct {
	Did       string // DID being migrated
	MigrateTo string // destination, may be empty
}

MigrateEvent represents a repository migration

type MigrateFilter

type MigrateFilter func(evt *MigrateEvent) bool

MigrateFilter is a function that filters Migrate events

type MigrateHandlerWithFilter

type MigrateHandlerWithFilter struct {
	Handler func(*MigrateEvent) error
	Filters []MigrateFilter
}

MigrateHandlerWithFilter combines a migrate handler with its filters

type OnHandleHandler

type OnHandleHandler struct {
	Filters []HandleFilter
	Handler func(evt *HandleEvent) error
}

OnHandleHandler handles handle events with optional filters

type OnInfoHandler

type OnInfoHandler struct {
	Filters []InfoFilter
	Handler func(evt *InfoEvent) error
}

OnInfoHandler handles info events with optional filters

type OnMigrateHandler

type OnMigrateHandler struct {
	Filters []MigrateFilter
	Handler func(evt *MigrateEvent) error
}

OnMigrateHandler handles migrate events with optional filters

type OnPostHandler

type OnPostHandler struct {
	Filters []PostFilter
	Handler func(post *post.Post) error
}

OnPostHandler handles post events with optional filters

type OnTombstoneHandler

type OnTombstoneHandler struct {
	Filters []TombstoneFilter
	Handler func(evt *TombstoneEvent) error
}

OnTombstoneHandler handles tombstone events with optional filters

type PostFilter

type PostFilter func(*post.Post) bool

PostFilter is a function that filters posts

type PostHandlerWithFilter

type PostHandlerWithFilter struct {
	Handler func(*post.Post) error
	Filters []PostFilter
}

PostHandlerWithFilter combines a post handler with its filters

type RawOperationHandler

type RawOperationHandler interface {
	HandleRawOperation(op *RepoOperation) error
}

RawOperationHandler handles raw operations

type RepoOperation

type RepoOperation struct {
	Action string // create, update, delete
	Path   string // record path
	Cid    string // content identifier
	Blocks []byte // CAR format blocks
}

RepoOperation represents an operation on a repository

func (*RepoOperation) DecodeRecord

func (op *RepoOperation) DecodeRecord(target any) error

DecodeRecord attempts to decode the record from blocks using the CID

type TombstoneEvent

type TombstoneEvent struct {
	Did  string // DID being tombstoned
	Time string // when it was tombstoned
}

TombstoneEvent represents a repository being tombstoned

type TombstoneFilter

type TombstoneFilter func(evt *TombstoneEvent) bool

TombstoneFilter is a function that filters Tombstone events

type TombstoneHandlerWithFilter

type TombstoneHandlerWithFilter struct {
	Handler func(*TombstoneEvent) error
	Filters []TombstoneFilter
}

TombstoneHandlerWithFilter combines a tombstone handler with its filters

Jump to

Keyboard shortcuts

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