feeds

package
v4.4.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2017 License: AGPL-3.0, AGPL-3.0-or-later Imports: 6 Imported by: 0

Documentation

Overview

Package feeds manages client synchronization to update feeds and provides a thread-safe interface for propagating messages to them and reassigning feeds to and from clients.

Index

Constants

View Source
const TickerInterval = time.Millisecond * 100

TickerInterval sets the interval of ticker flushes

Variables

This section is empty.

Functions

func All

func All() []common.Client

All returns all currently connected clients

func BanPost

func BanPost(id, op uint64) error

Propagate a message about a post being banned

func Clear

func Clear()

Remove all existing feeds and clients. Used only in tests.

func ClosePost

func ClosePost(id, op uint64, msg []byte)

ClosePost closes a post in a feed, if it exists

func DeleteImage

func DeleteImage(id, op uint64) error

Propagate a message about an image being deleted from a post

func DeletePost

func DeletePost(id, op uint64) error

Propagate a message about a post being deleted

func GetByIPAndBoard

func GetByIPAndBoard(ip, board string) []common.Client

GetByIPAndBoard retrieves all Clients that match the passed IP on a board

func GetSync

func GetSync(cl common.Client) (synced bool, op uint64, board string)

GetSync returns if the client is synced and the thread and board it is synced to.

func InsertPostInto

func InsertPostInto(post common.StandalonePost, msg []byte)

InsertPostInto inserts a post into a tread feed, if it exists. Only use for already closed posts.

func RemoveClient

func RemoveClient(cl common.Client)

RemoveClient removes a client from the global client map and any subscribed to feed

func SendTo

func SendTo(id uint64, msg []byte)

SendTo sends a message to a feed, if it exists

func SpoilerImage

func SpoilerImage(id, op uint64) error

Propagate a message about an image being spoilered

Types

type ClientMap

type ClientMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ClientMap is a thread-safe store for all clients connected to this server instance

type Feed

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

A feed with synchronization logic of a certain thread

func SyncClient

func SyncClient(cl common.Client, op uint64, board string) (*Feed, error)

SyncClient adds a client to a the global client map and synchronizes to an update feed, if any. If the client was already synced to another feed, it is automatically unsubscribed.

func (*Feed) ClosePost

func (f *Feed) ClosePost(id uint64, msg []byte)

func (*Feed) InsertImage

func (f *Feed) InsertImage(id uint64, msg []byte)

Insert an image into an already allocated post

func (*Feed) InsertPost

func (f *Feed) InsertPost(post common.StandalonePost, body, msg []byte)

Insert a new post into the thread or reclaim an open post after disconnect and propagate to listeners

func (*Feed) Send

func (f *Feed) Send(msg []byte)

Send a message to all listening clients

func (*Feed) SetOpenBody

func (f *Feed) SetOpenBody(id uint64, body, msg []byte)

Set body of an open post and send update message to clients

func (*Feed) SpoilerImage

func (f *Feed) SpoilerImage(id uint64, msg []byte)

func (*Feed) Start

func (f *Feed) Start() (err error)

Read existing posts into cache and start main loop

Jump to

Keyboard shortcuts

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