gitea: code.gitea.io/gitea/modules/eventsource Index | Files

package eventsource

import "code.gitea.io/gitea/modules/eventsource"

Index

Package Files

event.go manager.go manager_run.go messenger.go

type Event Uses

type Event struct {
    // Name represents the value of the event: tag in the stream
    Name string
    // Data is either JSONified []byte or interface{} that can be JSONd
    Data interface{}
    // ID represents the ID of an event
    ID  string
    // Retry tells the receiver only to attempt to reconnect to the source after this time
    Retry time.Duration
}

Event is an eventsource event, not all fields need to be set

func (*Event) String Uses

func (e *Event) String() string

func (*Event) WriteTo Uses

func (e *Event) WriteTo(w io.Writer) (int64, error)

WriteTo writes data to w until there's no more data to write or when an error occurs. The return value n is the number of bytes written. Any error encountered during the write is also returned.

type Manager Uses

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

Manager manages the eventsource Messengers

func GetManager Uses

func GetManager() *Manager

GetManager returns a Manager and initializes one as singleton if there's none yet

func (*Manager) Init Uses

func (m *Manager) Init()

Init starts this eventsource

func (*Manager) Register Uses

func (m *Manager) Register(uid int64) <-chan *Event

Register message channel

func (*Manager) Run Uses

func (m *Manager) Run(ctx context.Context)

Run runs the manager within a provided context

func (*Manager) SendMessage Uses

func (m *Manager) SendMessage(uid int64, message *Event)

SendMessage sends a message to a particular user

func (*Manager) SendMessageBlocking Uses

func (m *Manager) SendMessageBlocking(uid int64, message *Event)

SendMessageBlocking sends a message to a particular user

func (*Manager) Unregister Uses

func (m *Manager) Unregister(uid int64, channel <-chan *Event)

Unregister message channel

func (*Manager) UnregisterAll Uses

func (m *Manager) UnregisterAll()

UnregisterAll message channels

type Messenger Uses

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

Messenger is a per uid message store

func NewMessenger Uses

func NewMessenger(uid int64) *Messenger

NewMessenger creates a messenger for a particular uid

func (*Messenger) Register Uses

func (m *Messenger) Register() <-chan *Event

Register returns a new chan []byte

func (*Messenger) SendMessage Uses

func (m *Messenger) SendMessage(message *Event)

SendMessage sends the message to all registered channels

func (*Messenger) SendMessageBlocking Uses

func (m *Messenger) SendMessageBlocking(message *Event)

SendMessageBlocking sends the message to all registered channels and ensures it gets sent

func (*Messenger) Unregister Uses

func (m *Messenger) Unregister(channel <-chan *Event) bool

Unregister removes the provider chan []byte

func (*Messenger) UnregisterAll Uses

func (m *Messenger) UnregisterAll()

UnregisterAll removes all chan []byte

Package eventsource imports 13 packages (graph) and is imported by 12 packages. Updated 2020-07-22. Refresh now. Tools for package owners.