Documentation
¶
Overview ¶
This event bridge allows different instances of babou to securely exchange messages which help keep the website and tracker in sync.
Index ¶
- Constants
- func DeleteTorrent(torrentHash string)
- func DeleteUser(userId int)
- type Bridge
- func (b *Bridge) APublish(msg *Message) <-chan int
- func (b *Bridge) AddTransport(transport Transport)
- func (b *Bridge) Close() chan bool
- func (b *Bridge) NewLocalTransport() *LocalTransport
- func (b *Bridge) Publish(name string, msg *Message)
- func (b *Bridge) Subscribe(name string, c chan<- *Message)
- type DeleteTorrentMessage
- type DeleteUserMessage
- type LocalTransport
- type Message
- type MessageType
- type Packet
- type TCPTransport
- type TorrentStatMessage
- type Transport
- type TransportError
- type UnixTransport
Constants ¶
const ( BRIDGE_SEND_BUFFER int = 10 BRIDGE_RECV_BUFFER = 10 )
Variables ¶
This section is empty.
Functions ¶
func DeleteTorrent ¶
func DeleteTorrent(torrentHash string)
Instructs trackers to remove a torrent from their cache ASAP
func DeleteUser ¶
func DeleteUser(userId int)
Instructs trackers to remove a user from their cache ASAP
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Represents the programs bridge to send messages to the other pack members. The default route will discard all messages sent through the bridge.
func NewBridge ¶
func NewBridge(settings *lib.TransportSettings) *Bridge
Sets up a bridge w/ a send buffer attached to nothing. All messages will be dropped to drain the buffer until transport(s) are available.
func (*Bridge) APublish ¶
Returns a channel immediately.
When the bridge has sucesfully placed your message into the send buffer, a single integer will be sent on the returned channel.
func (*Bridge) AddTransport ¶
TODO: Recover from connection failure.
func (*Bridge) NewLocalTransport ¶
func (b *Bridge) NewLocalTransport() *LocalTransport
Forwards message to locally available transport. Must be used on an existing bridge.
type DeleteTorrentMessage ¶
type DeleteUserMessage ¶
type DeleteUserMessage struct {
UserId int
}
type LocalTransport ¶
type LocalTransport struct {
// contains filtered or unexported fields
}
func (*LocalTransport) Send ¶
func (lt *LocalTransport) Send(msg *Packet)
Loop packet around to bridge's inbox.
type Message ¶
type Message struct { Type MessageType Payload interface{} }
message wrapper for quick decoding on other end.
func TorrentStats ¶
Creates a torrent-stat tuple
type MessageType ¶
type MessageType uint8
const ( UPDATE_USER_KEY MessageType = iota CHANGE_USER_TOKEN WATCH_USERS DELETE_USER DISABLE_USER DELETE_TORRENT DISABLE_TORRENT TORRENT_STAT_TUPLE )
type TCPTransport ¶
type TCPTransport struct {
// contains filtered or unexported fields
}
func NewTCPTransport ¶
func NewTCPTransport(socketAddr string) *TCPTransport
func (*TCPTransport) Send ¶
func (tcp *TCPTransport) Send(msg *Packet)
type TorrentStatMessage ¶
type Transport ¶
type Transport interface {
Send(msg *Packet) // Sends a message to the specified socket
}
type TransportError ¶
type TransportError int
const (
TRANSPORT_NOT_AVAILABLE TransportError = iota
)
type UnixTransport ¶
type UnixTransport struct {
// contains filtered or unexported fields
}
func NewUnixTransport ¶
func NewUnixTransport(socketAddr string) *UnixTransport
func (*UnixTransport) Send ¶
func (ut *UnixTransport) Send(msg *Packet)