model

package
v0.0.0-kmdagger1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelClientCount

type ChannelClientCount func(orgID int64, channel string) (int, error)

ChannelClientCount will return the number of clients for a channel

type ChannelHandler

type ChannelHandler interface {
	// OnSubscribe is called when a client wants to subscribe to a channel
	OnSubscribe(ctx context.Context, user *user.SignedInUser, e SubscribeEvent) (SubscribeReply, backend.SubscribeStreamStatus, error)

	// OnPublish is called when a client writes a message to the channel websocket.
	OnPublish(ctx context.Context, user *user.SignedInUser, e PublishEvent) (PublishReply, backend.PublishStreamStatus, error)
}

ChannelHandler defines the core channel behavior

type ChannelHandlerFactory

type ChannelHandlerFactory interface {
	// GetHandlerForPath gets a ChannelHandler for a path.
	// This is called fast and often -- it must be synchronized
	GetHandlerForPath(path string) (ChannelHandler, error)
}

ChannelHandlerFactory should be implemented by all core features.

type ChannelPublisher

type ChannelPublisher func(orgID int64, channel string, data []byte) error

ChannelPublisher writes data into a channel. Note that permissions are not checked.

type GetLiveMessageQuery

type GetLiveMessageQuery struct {
	OrgID   int64 `xorm:"org_id"`
	Channel string
}

type LiveMessage

type LiveMessage struct {
	ID        int64 `xorm:"pk autoincr 'id'"`
	OrgID     int64 `xorm:"org_id"`
	Channel   string
	Data      json.RawMessage
	Published time.Time
}

type PublishEvent

type PublishEvent struct {
	Channel string
	Path    string
	Data    json.RawMessage
}

PublishEvent contains publication data.

type PublishReply

type PublishReply struct {
	// By default, it's a handler responsibility to publish data
	// into a stream upon OnPublish but returning a data here
	// will make Grafana Live publish data itself (i.e. stream handler
	// just works as permission proxy in this case).
	Data json.RawMessage
	// HistorySize sets a stream history size.
	HistorySize int
	// HistoryTTL is a time that messages will live in stream history.
	HistoryTTL time.Duration
}

PublishReply is a reaction to PublishEvent.

type SaveLiveMessageQuery

type SaveLiveMessageQuery struct {
	OrgID   int64 `xorm:"org_id"`
	Channel string
	Data    json.RawMessage
}

type SubscribeEvent

type SubscribeEvent struct {
	Channel string
	Path    string
	Data    json.RawMessage
}

SubscribeEvent contains subscription data.

type SubscribeReply

type SubscribeReply struct {
	Presence  bool
	JoinLeave bool
	Recover   bool
	Data      json.RawMessage
}

SubscribeReply is a reaction to SubscribeEvent.

Jump to

Keyboard shortcuts

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