udspubsub

package module
v0.0.0-...-660fb7e Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2020 License: MIT Imports: 4 Imported by: 0

README

udspubsub

pubsub implementation using unix domain socket in golang

Install

go get -u github.com/Sab94/udspubsub

Examples

Check out the example and the test

Project52

It is one of my project 52.

Documentation

Index

Constants

View Source
const (
	PUBLISH     = "publish"
	SUBSCRIBE   = "subscribe"
	UNSUBSCRIBE = "unsubscribe"
)
View Source
const MAX_BUFFER = 1024

Variables

View Source
var Topics = []string{}

Functions

This section is empty.

Types

type Client

type Client struct {
	Id         string
	Connection net.Conn
}

type Message

type Message struct {
	Action  string `json:"action"`
	Topic   string `json:"topic"`
	Message []byte `json:"message"`
}

type PubSubClient

type PubSubClient struct {
	ID string
	// contains filtered or unexported fields
}

func NewPubSubClient

func NewPubSubClient(socketPath string) (*PubSubClient, error)

func (*PubSubClient) Publish

func (p *PubSubClient) Publish(topic string, message []byte) error

func (*PubSubClient) Subscribe

func (p *PubSubClient) Subscribe(topic string) (chan string, error)

func (*PubSubClient) Unsubscribe

func (p *PubSubClient) Unsubscribe(topic string) error

type PubSubHandler

type PubSubHandler struct {
	Clients       []Client
	Subscriptions []Subscription
}

func Listener

func Listener(socketPath string) *PubSubHandler

func (*PubSubHandler) GetClientSubscriptions

func (ps *PubSubHandler) GetClientSubscriptions(client *Client) []Subscription

func (*PubSubHandler) GetTopicSubscriptions

func (ps *PubSubHandler) GetTopicSubscriptions(topic string) []Subscription

func (*PubSubHandler) IsClientSubscribed

func (ps *PubSubHandler) IsClientSubscribed(topic string, client *Client) bool

type Subscription

type Subscription struct {
	Topic  string
	Client *Client
}

Directories

Path Synopsis
example
listener command
publisher command
subscriber command

Jump to

Keyboard shortcuts

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