kratos

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

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

Go to latest
Published: Oct 20, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

README

kratos, the client emulator

Build Status codecov.io Go Report Card

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

How to Install

This project uses glide to manage its dependencies. To install, first download glide at the provided link, and then create a glide.yaml in $GOPATH/src/myProject (where myProject is the project that you're using kratos with). Running glide install with a properly formatted glide.yaml should pull down kratos and then all the dependencies that kratos has.

Sample glide.yaml to Build kratos/example/main.go

Below is a sample glide.yaml that you can use in conjunction with the instructions (located further down in this README).

package: myProject
import:
- package: github.com/Comcast/kratos

Instructions for Building Sample main.go File:

  • make sure that you have golang installed and running
  • make sure that you have glide installed
  • change directories in your computer to the directory that you want kratos to live in (henceforth called <root>)
  • we’ll call the “project” we’re creating to run the kratos sample file myProject
$ #create the directories for myProject from <root>
$ mkdir -p myProject/src/myProject
$
$ # move in to the top level of the newly created directory and
$ # set your $GOPATH to point there (this is for dependencies and such)
$ cd <root>/myProject
$ export GOPATH=`pwd`
$
$ # put the provided glide.yaml file (shown above),
$ # in the directory <root>/myProject/src/myProject
$
$ # run `glide install` from <root>/myProject/src/myProject
$ # (will only work if you put the `glide.yaml` file in this directory)
$ glide install
$
$ # copy the main.go file included in kratos into <root>/myProject/src/myProject
$ cd <root>/myProject/src/myProject
$ cp <root>/myProject/src/myProject/vendor/github.com/Comcast/kratos/example/main.go .
$
$ # run `glide up` so we can grab the stuff that `main.go` says it needs
$ # these weren't grabbed initially by glide since glide didn't have any import
$ # statements to look at within code
$ cd <root>/myProject/src/myProject
$ glide up
$
$ # change directories to <root>/myProject/src/myProject and build myProject
$ cd <root>/myProject/src/myProject
$ go build
$
$ # run the example file
$ ./myProject

Documentation

Index

Constants

This section is empty.

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
	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 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 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