stream

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EventTypeNotification -- a user
	// should be shown a notification.
	EventTypeNotification = "notification"

	// EventTypeUpdate -- a user should
	// be shown an update in their timeline.
	EventTypeUpdate = "update"

	// EventTypeDelete -- something
	// should be deleted from a user.
	EventTypeDelete = "delete"

	// EventTypeStatusUpdate -- something in the
	// user's timeline has been edited (yes this
	// is a confusing name, blame Mastodon ...).
	EventTypeStatusUpdate = "status.update"
)
View Source
const (
	// TimelineLocal:
	// All public posts originating from this
	// server. Analogous to the local timeline.
	TimelineLocal = "public:local"

	// TimelinePublic:
	// All public posts known to the server.
	// Analogous to the federated timeline.
	TimelinePublic = "public"

	// TimelineHome:
	// Events related to the current user, such
	// as home feed updates and notifications.
	TimelineHome = "user"

	// TimelineNotifications:
	// Notifications for the current user.
	TimelineNotifications = "user:notification"

	// TimelineDirect:
	// Updates to direct conversations.
	TimelineDirect = "direct"

	// TimelineList:
	// Updates to a specific list.
	TimelineList = "list"
)

Variables

AllStatusTimelines contains all Timelines that a status could conceivably be delivered to, useful for sending out status deletes.

Functions

This section is empty.

Types

type Message

type Message struct {

	// All the stream types this
	// message should be delivered to.
	Stream []string `json:"stream"`

	// The event type of the message
	// (update/delete/notification etc)
	Event string `json:"event"`

	// The actual payload of the message. In case of an
	// update or notification, this will be a JSON string.
	Payload string `json:"payload"`
}

Message represents one streamed message.

type Stream

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

Stream represents one open stream for a client.

func (*Stream) Close added in v0.14.0

func (s *Stream) Close()

Close will close the underlying context, finally removing it from the parent Streams per-account-map.

func (*Stream) Recv added in v0.14.0

func (s *Stream) Recv(ctx context.Context) (Message, bool)

Recv will block on receiving Message{}, returning early with a false value if provided context is canceled, or stream closed.

func (*Stream) Subscribe added in v0.14.0

func (s *Stream) Subscribe(streamType string)

Subscribe will add given type to given types this stream supports.

func (*Stream) Unsubscribe added in v0.14.0

func (s *Stream) Unsubscribe(streamType string)

Unsubscribe will remove given type (if found) from types this stream supports.

type Streams added in v0.14.0

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

func (*Streams) Open added in v0.14.0

func (s *Streams) Open(accountID string, streamTypes ...string) *Stream

Open will open open a new Stream for given account ID and stream types, the given context will be passed to Stream.

func (*Streams) Post added in v0.14.0

func (s *Streams) Post(ctx context.Context, accountID string, msg Message) bool

Post will post the given message to all streams of given account ID matching type.

func (*Streams) PostAll added in v0.14.0

func (s *Streams) PostAll(ctx context.Context, msg Message) bool

PostAll will post the given message to all streams with matching types.

Jump to

Keyboard shortcuts

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