Version: v0.0.0-...-f18cc39 Latest Latest

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

Go to latest
Published: Oct 13, 2013 License: BSD-3-Clause, MIT Imports: 5 Imported by: 0



This event bridge allows different instances of babou to securely exchange messages which help keep the website and tracker in sync.



View Source
const (


This section is empty.


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


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

func (b *Bridge) APublish(msg *Message) <-chan int

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

func (b *Bridge) AddTransport(transport Transport)

TODO: Recover from connection failure.

func (*Bridge) Close

func (b *Bridge) Close() chan bool

func (*Bridge) NewLocalTransport

func (b *Bridge) NewLocalTransport() *LocalTransport

Forwards message to locally available transport. Must be used on an existing bridge.

func (*Bridge) Publish

func (b *Bridge) Publish(name string, msg *Message)

Sends a message on a channel. Will block indefinitely if the send-buffer is filled and not being drained.

name: name of a receiver you're listening on [so you will not recv this message]

func (*Bridge) Subscribe

func (b *Bridge) Subscribe(name string, c chan<- *Message)

Provide a channel for us to send events too. When a new event is published you will receive it.

type DeleteTorrentMessage

type DeleteTorrentMessage struct {
	InfoHash string
	Reason   string

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

func TorrentStats(
	infoHash string,
	leeching int) *Message

Creates a torrent-stat tuple

type MessageType

type MessageType uint8
const (
	UPDATE_USER_KEY MessageType = iota






type Packet

type Packet struct {
	SubscriberName string
	Payload        *Message

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 TorrentStatMessage struct {
	InfoHash string
	Seeding  int
	Leeching int

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)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL