kratos

package module
v0.0.0-...-748357d Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

README

kratos, the client emulator

Build Status codecov.io Go Report Card Apache V2 License GitHub release

Websocket wrapper that provides a simple API for making new connections, sending messages on that connection, and providing a way to handle received messages.

Table of Contents

Code of Conduct

This project and everyone participating in it are governed by the XMiDT Code Of Conduct. By participating, you agree to this Code.

How to Install

This project uses go modules to manage its dependencies. This is best used with go 1.12+. to import this module, run:

go get github.com/xmidt-org/kratos@latest

or add it to your go.mod file for your project.

Contributing

Refer to CONTRIBUTING.md.

Documentation

Index

Constants

View Source
const (
	StatusDeviceDisconnected int = 523
	StatusDeviceTimeout      int = 524
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Hostname() string
	Send(message interface{}) error
	Close() error
}

Client is what function calls we expose to the user of kratos

type ClientFactory

type ClientFactory struct {
	DeviceName     string
	FirmwareName   string
	ModelName      string
	Manufacturer   string
	DestinationURL string
	CRT            string
	Key            string
	Handlers       []HandlerRegistry
	HandlePingMiss HandlePingMiss
	ClientLogger   log.Logger
}

ClientFactory is used to generate a client by calling new on this type

func (*ClientFactory) New

func (f *ClientFactory) New() (Client, error)

New is used to create a new kratos Client from a ClientFactory

type Error

type Error struct {
	Message  Message
	SubError error
}

func (*Error) Error

func (e *Error) Error() string

type HandlePingMiss

type HandlePingMiss func() error

HandlePingMiss is a function called when we run into situations where we're not getting anymore pings the implementation of this function needs to be handled by the user of kratos

type HandlerRegistry

type HandlerRegistry struct {
	HandlerKey string

	Handler ReadHandler
	// contains filtered or unexported fields
}

HandlerRegistry is an internal data type for Client interface that helps keep track of registered handler functions

type Message

type Message struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (Message) String

func (msg Message) String() string

type ReadHandler

type ReadHandler interface {
	HandleMessage(msg interface{})
}

ReadHandler should be implemented by the user so that they may deal with received messages how they please

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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