transport

package module
v0.0.0-...-ad83253 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: Apache-2.0 Imports: 32 Imported by: 1

README

package main

import (
    "fmt"
    "log"
    
    app "./go"
    transport "github.com/peramic/transport"
)

func main() {
    app.AddRoutes(transport.TransportRoutes)

    log.Printf("Server started")

    router := app.NewRouter()

    log.Fatal(http.ListenAndServe(":8080", router))
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TransportRoutes = []utils.Route{

	utils.Route{
		Name:        "GetSubscribers",
		Method:      strings.ToUpper("Get"),
		Pattern:     "/rest/subscribers",
		HandlerFunc: getSubscribers,
	},
	utils.Route{
		Name:        "SetPassphrase",
		Method:      strings.ToUpper("Post"),
		Pattern:     "/rest/subscribers/certs/passphrase",
		HandlerFunc: setPassphrase,
	},
	utils.Route{
		Name:        "HasTrusted",
		Method:      strings.ToUpper("Get"),
		Pattern:     "/rest/subscribers/{id}/certs/trust",
		HandlerFunc: hasTrusted,
	},
	utils.Route{
		Name:        "DeleteTrusted",
		Method:      strings.ToUpper("Delete"),
		Pattern:     "/rest/subscribers/{id}/certs/trust",
		HandlerFunc: deleteTrusted,
	},
	utils.Route{
		Name:        "SetTrusted",
		Method:      strings.ToUpper("Post"),
		Pattern:     "/rest/subscribers/{id}/certs/trust",
		HandlerFunc: setTrusted,
	},
	utils.Route{
		Name:        "HasKeyStore",
		Method:      strings.ToUpper("Get"),
		Pattern:     "/rest/subscribers/{id}/certs/keystore",
		HandlerFunc: hasKeyStore,
	},
	utils.Route{
		Name:        "DeleteKeyStore",
		Method:      strings.ToUpper("Delete"),
		Pattern:     "/rest/subscribers/{id}/certs/keystore",
		HandlerFunc: deleteKeyStore,
	},
	utils.Route{
		Name:        "setKeyStore",
		Method:      strings.ToUpper("Post"),
		Pattern:     "/rest/subscribers/{id}/certs/keystore",
		HandlerFunc: setKeyStore,
	},
	utils.Route{
		Name:        "AddSubscriber",
		Method:      strings.ToUpper("Post"),
		Pattern:     "/rest/subscribers",
		HandlerFunc: addSubscriber,
	},
	utils.Route{
		Name:        "GetSubscriber",
		Method:      strings.ToUpper("Get"),
		Pattern:     "/rest/subscribers/{id}",
		HandlerFunc: getSubscriber,
	},
	utils.Route{
		Name:        "setSubscriber",
		Method:      strings.ToUpper("Put"),
		Pattern:     "/rest/subscribers/{id}",
		HandlerFunc: setSubscriber,
	},
	utils.Route{
		Name:        "deleteSubscriber",
		Method:      strings.ToUpper("Delete"),
		Pattern:     "/rest/subscribers/{id}",
		HandlerFunc: deleteSubscriber,
	},
}

TransportRoutes Transport Library Routes

Functions

func AddSubscriptor

func AddSubscriptor(sub Subscriptor) error

AddSubscriptor add a subscriptor

func DefineSubscriptor

func DefineSubscriptor(sub Subscriptor) (string, error)

DefineSubscriptor define a subscriptor

func DeleteSubscriptor

func DeleteSubscriptor(id string) error

DeleteSubscriptor deletes a subscriptor

func UpdateSubscriptor

func UpdateSubscriptor(sub Subscriptor) error

UpdateSubscriptor update a subscriptor

Types

type MemoryStore

type MemoryStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MemoryStore implements the store interface to provide a "persistence" mechanism wholly stored in memory. This is only useful for as long as the client instance exists.

func NewMemoryStore

func NewMemoryStore(size int) *MemoryStore

NewMemoryStore returns a pointer to a new instance of MemoryStore, the instance is not initialized and ready to use until Open() has been called on it.

func (*MemoryStore) All

func (store *MemoryStore) All() []string

All returns a slice of strings containing all the keys currently in the MemoryStore.

func (*MemoryStore) Close

func (store *MemoryStore) Close()

Close will disallow modifications to the state of the store.

func (*MemoryStore) Del

func (store *MemoryStore) Del(key string)

Del takes a key, searches the MemoryStore and if the key is found deletes the Message pointer associated with it.

func (*MemoryStore) Get

func (store *MemoryStore) Get(key string) packets.ControlPacket

Get takes a key and looks in the store for a matching Message returning either the Message pointer or nil.

func (*MemoryStore) Open

func (store *MemoryStore) Open()

Open initializes a MemoryStore instance.

func (*MemoryStore) Put

func (store *MemoryStore) Put(key string, message packets.ControlPacket)

Put takes a key and a pointer to a Message and stores the message.

func (*MemoryStore) Reset

func (store *MemoryStore) Reset()

Reset eliminates all persisted message data in the store.

type Provider

type Provider interface {
	Publish(topic string, m interface{})
	Shutdown()
	SetTLS(id string) error
}

Provider provider interface

type Subscriber

type Subscriber struct {
	ID         string            `json:"id,omitempty"`
	Enable     bool              `json:"enable"`
	URI        string            `json:"uri,omitempty"`
	Properties map[string]string `json:"properties"`
	Provider   Provider          `json:"-"`
}

Subscriber subscriber structure

type SubscriberConfiguration

type SubscriberConfiguration struct {
	Subscribers map[string]*Subscriber `json:"subscribers,omitempty"`
	// contains filtered or unexported fields
}

SubscriberConfiguration subscriber configuration

type Subscriptor

type Subscriptor struct {
	ID           string            `json:"id,omitempty"`
	Enable       bool              `json:"enable"`
	Name         string            `json:"name,omitempty"`
	Path         string            `json:"path,omitempty"`
	SubscriberID string            `json:"subscriberId,omitempty"`
	Properties   map[string]string `json:"properties"`
}

Subscriptor subscriptor structure

func (Subscriptor) SendReport

func (subscriptor Subscriptor) SendReport(report interface{})

SendReport --send a report

Jump to

Keyboard shortcuts

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