pipes

package module
v0.0.0-...-4b8ecad Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

README

pipes

Pipes is a framework we use at Fajurion to handle real-time messaging for our chat app. It works across multiple nodes with multiple servers for ultimate scalability. It currently works with UDP and WebSockets. There is still some need for performance improvements in the future, but it will be fine for small applications.

There is also no documentation as of writing this, there'll eventually be a documentation page for this API, but that'll happen when it is fully released.

NOTE: Pipes is currently in early stages, I'm not sure how I'll design the final API when it's released: All API features are subject to change.

Documentation

Index

Constants

View Source
const ChannelBroadcast = "br"
View Source
const ChannelConversation = "c"
View Source
const ChannelP2P = "p"

Variables

View Source
var DebugLogs = false
View Source
var Log = log.New(log.Writer(), "pipes ", log.Flags())

Functions

func AddNode

func AddNode(node Node)

func DeleteNode

func DeleteNode(node string)

func IterateNodes

func IterateNodes(callback func(string, Node) bool)

IterateConnections iterates over all connections. If the callback returns false, the iteration stops.

func SetupCurrent

func SetupCurrent(id string, token string)

func SetupSocketless

func SetupSocketless(sl string)

func SetupUDP

func SetupUDP(udp string)

func SetupWS

func SetupWS(ws string)

Types

type Channel

type Channel struct {
	Channel string   `json:"channel"` // Channel name
	Target  []string `json:"target"`  // User IDs to send to (node and user ID for p2p channel)
	Nodes   []string `json:"-"`       // Nodes to send to (only for conversation channel)
}

func BroadcastChannel

func BroadcastChannel(receivers []string) Channel

func Conversation

func Conversation(receivers []string, nodes []string) Channel

func P2PChannel

func P2PChannel(receiver string, receiverNode string) Channel

func (Channel) IsBroadcast

func (c Channel) IsBroadcast() bool

func (Channel) IsConversation

func (c Channel) IsConversation() bool

func (Channel) IsP2P

func (c Channel) IsP2P() bool

type Event

type Event struct {
	Name string                 `json:"name"`
	Data map[string]interface{} `json:"data"`
}

type Message

type Message struct {
	Channel Channel `json:"channel"`
	Event   Event   `json:"event"`
	Local   bool    `json:"-"` // Whether to only send to local clients (excluded from JSON)
}

type Node

type Node struct {
	ID    string `json:"id"`
	Token string `json:"token"`
	WS    string `json:"ws,omitempty"`  // Websocket ip
	UDP   string `json:"udp,omitempty"` // UDP ip
	SL    string `json:"sl,omitempty"`  // Socketless pipe

	// Encryption
	Cipher cipher.Block `json:"-"`
}
var CurrentNode Node

func GetNode

func GetNode(id string) *Node

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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