connmgr

package
v0.0.0-...-ef41e9a Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UploadID   string = "/upload"
	DownloadID string = "/download"
	QueryID    string = "/query"
)

Variables

This section is empty.

Functions

func DownloadDag

func DownloadDag(ctx context.Context, connectionManager ConnectionManager, connectionID string, root string, publicKey *string, signature *string, filter *types.DownloadFilter, progressChan chan<- types.DownloadProgress) (context.Context, *merkle_dag.Dag, error)

func QueryDag

func QueryDag(ctx context.Context, connectionManager ConnectionManager, connectionID string, query map[string]string) (context.Context, *[]string, error)

func QueryEvents

func QueryEvents(ctx context.Context, connectionManager ConnectionManager, connectionID string, filters []nostr.Filter, subscriptionId *string) ([]nostr.Event, error)

func ReadJsonMessageFromStream

func ReadJsonMessageFromStream[T any](stream types.Stream) (*T, error)

func ReadMessageFromStream

func ReadMessageFromStream[T any](stream types.Stream) (*T, error)

func SendUniversalEvent

func SendUniversalEvent(ctx context.Context, connectionManager ConnectionManager, event *nostr.Event, subscriptionId *string) (map[string]*nostr.OKEnvelope, error)

func SendUniversalEventSingle

func SendUniversalEventSingle(ctx context.Context, connectionManager ConnectionManager, connectionID string, event *nostr.Event, subscriptionId *string) (*nostr.OKEnvelope, error)

func SetupConnection

func SetupConnection(useLibp2p bool, address string) (types.Connector, error)

func UploadDag

func UploadDag(ctx context.Context, connectionManager ConnectionManager, dag *merkle_dag.Dag, publicKey *string, signature *string, progressChan chan<- types.UploadProgress) error

func UploadDagSingle

func UploadDagSingle(ctx context.Context, connectionManager ConnectionManager, connectionID string, dag *merkle_dag.Dag, publicKey *string, signature *string, progressChan chan<- types.UploadProgress) error

func WaitForResponse

func WaitForResponse(ctx context.Context, stream types.Stream) bool

func WaitForUploadMessage

func WaitForUploadMessage(ctx context.Context, stream types.Stream) (bool, *types.UploadMessage)

func WriteJsonMessageToStream

func WriteJsonMessageToStream[T any](stream types.Stream, message T) error

func WriteMessageToStream

func WriteMessageToStream[T any](stream types.Stream, message T) error

func WriteResponseToStream

func WriteResponseToStream(ctx context.Context, stream types.Stream, response bool) error

Types

type ConnectionManager

type ConnectionManager interface {
	ConnectWithLibp2p(ctx context.Context, connectionId string, serverAddress string, opts ...libp2p.Option) error
	ConnectWithWebsocket(ctx context.Context, connectionId string, url string) error
	Disconnect(connectionID string) error
	GetStream(ctx context.Context, connectionID string, protocolID string) (types.Stream, error)
	ListConnections() map[string]types.Connector
}

type GenericConnectionManager

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

func NewGenericConnectionManager

func NewGenericConnectionManager() *GenericConnectionManager

func (*GenericConnectionManager) ConnectWithLibp2p

func (gcm *GenericConnectionManager) ConnectWithLibp2p(ctx context.Context, connectionId string, serverAddress string, opts ...libp2p.Option) error

func (*GenericConnectionManager) ConnectWithWebsocket

func (gcm *GenericConnectionManager) ConnectWithWebsocket(ctx context.Context, connectionId string, url string) error

func (*GenericConnectionManager) Disconnect

func (gcm *GenericConnectionManager) Disconnect(connectionID string) error

func (*GenericConnectionManager) GetStream

func (gcm *GenericConnectionManager) GetStream(ctx context.Context, connectionID string, protocolID string) (types.Stream, error)

func (*GenericConnectionManager) ListConnections

func (gcm *GenericConnectionManager) ListConnections() map[string]types.Connector

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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