topserve: github.com/hadidimad/topserve Index | Files

package topserve

import "github.com/hadidimad/topserve"

Index

Package Files

client.go server.go

type Client Uses

type Client struct {
    YourPublishers  map[string]struct{}
    YourSubscribers map[string]struct{}
    Err             chan string
    // contains filtered or unexported fields
}

Client struct

func (*Client) DeRegisterPublisher Uses

func (cl *Client) DeRegisterPublisher(name string) error

DeRegisterPublisher will remove you from server publisher for this event

func (*Client) DeRegisterSubscriber Uses

func (cl *Client) DeRegisterSubscriber(name string) error

DeRegisterSubscriber will remove you from the event subscribers so you will not recive event

func (*Client) End Uses

func (cl *Client) End()

func (*Client) HandleIncomings Uses

func (cl *Client) HandleIncomings()

HandleIncomings will recive and process them this should be routine after making new client

func (*Client) New Uses

func (cl *Client) New(address string) (Client, error)

New will make new client and connect it to server in address

func (*Client) Publish Uses

func (cl *Client) Publish(name string, v interface{}) error

Publish should run when event happens this will run event handlers

func (*Client) PublishServer Uses

func (cl *Client) PublishServer(name string, v interface{}) error

PublishServer will notify server that this event happend

func (*Client) RegisterPublisher Uses

func (cl *Client) RegisterPublisher(name string) error

RegisterPublisher will Register you as publisher of event at server

func (*Client) RegisterSubscriber Uses

func (cl *Client) RegisterSubscriber(name string) error

RegisterSubscriber will register you as event subscriber in server to recive event

func (*Client) Subscribe Uses

func (cl *Client) Subscribe(name string, h handler) error

Subscribe will subscribe handle function to event

type Message Uses

type Message struct {
    Mode string
    Data interface{}
}

Message use to commiunicate between server and client

type Publisher Uses

type Publisher struct {
    Name        string
    Conn        net.Conn
    Subscribers map[*Subscriber]struct{}
}

Publisher publishers use for notify subscibers about event

func (*Publisher) DeRegisterSubscriber Uses

func (p *Publisher) DeRegisterSubscriber(c net.Conn) error

DeRegisterSubscriber will remove c client from publisher subscribers

func (*Publisher) Publish Uses

func (p *Publisher) Publish(v interface{}) error

Publish will notify subscriber that event happens

func (*Publisher) RegisterSubscriber Uses

func (p *Publisher) RegisterSubscriber(c net.Conn) error

RegisterSubscriber will add client to this pubilsher subscribers by giving client connection

type Server Uses

type Server struct {
    Listener   net.Listener
    Publishers map[*Publisher]struct{}
}

Server struct

func (*Server) AcceptConnection Uses

func (s *Server) AcceptConnection() (net.Conn, error)

AcceptConnection will accpet new connections to clients

func (*Server) DeRegisterPublisher Uses

func (s *Server) DeRegisterPublisher(name string, conn net.Conn) error

DeRegisterPublisher will remove this publisher from server

func (*Server) DeRegisterSubscriber Uses

func (s *Server) DeRegisterSubscriber(name string, c net.Conn) error

DeRegisterSubscriber will remove subscriber from this publisher in server

func (*Server) End Uses

func (s *Server) End()

func (*Server) HandleConnection Uses

func (s *Server) HandleConnection(c net.Conn)

HandleConnection will recive messages from client and procces them this should be routine after accepted new connection

func (*Server) New Uses

func (s *Server) New(address string) (Server, error)

New will make new server

func (*Server) Publish Uses

func (s *Server) Publish(name string, v interface{}) error

Publish will notify publisher that event happend

func (*Server) RegisterPublisher Uses

func (s *Server) RegisterPublisher(name string, conn net.Conn) error

RegisterPublisher will add new publisher to server

func (*Server) RegisterSubscriber Uses

func (s *Server) RegisterSubscriber(name string, c net.Conn) error

RegisterSubscriber will add new Subscriber for a publisher in server

type Subscriber Uses

type Subscriber struct {
    Conn net.Conn
}

Subscriber will give the event

Package topserve imports 4 packages (graph). Updated 2017-07-17. Refresh now. Tools for package owners.