protocol

package
v0.0.0-...-4bed82c Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package protocol defines the communication between the components of the Kite infrastructure. It defines some constants and structures designed to be sent between those components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	// Type can be "kiteKey", "token" or "sessionID" for now.
	Type string `json:"type"`
	Key  string `json:"key"`
}

type GetKitesArgs

type GetKitesArgs struct {
	Query         *KontrolQuery   `json:"query"`
	WatchCallback dnode.Function  `json:"watchCallback"`
	Who           json.RawMessage `json:"who"`
}

type GetKitesResult

type GetKitesResult struct {
	Kites []*KiteWithToken `json:"kites"`
}

type GetTokenArgs

type GetTokenArgs struct {
	KontrolQuery // kite to generate a token for

	Force bool `json:"force"` // force creation of a new token
}

GetTokenArgs is a request value for the "getToken" kontrol method.

type Kite

type Kite struct {
	// Short name identifying the type of the kite. Example: fs, terminal...
	Name string `json:"name"`

	// Owner of the Kite
	Username string `json:"username"`

	// Every Kite instance has different identifier.
	// If a kite is restarted, it's id will change.
	// This is generated on the Kite.
	ID string `json:"id"`

	// Environment is defines as something like "production", "testing",
	// "staging" or whatever.  This allows you to differentiate between a
	// cluster of kites.
	Environment string `json:"environment"`

	// Region of the kite it is running. Like "Europe", "Asia" or some other
	// locations.
	Region string `json:"region"`

	// 3-digit semantic version.
	Version string `json:"version"`

	// os.Hostname() of the Kite.
	Hostname string `json:"hostname"`
}

Kite is the base struct containing the public fields. It is usually embedded in other structs, including the db model. The access model is in the form: username.environment.name.version.region.hostname.id

func KiteFromString

func KiteFromString(s string) (*Kite, error)

KiteFromString returns a new Kite string from the given string representation in the form of "/username/environment/...". It's the inverse of k.String()

func (*Kite) Query

func (k *Kite) Query() *KontrolQuery

Query() returns a pointer to KontrolQuery struct.

func (Kite) String

func (k Kite) String() string

func (*Kite) Validate

func (k *Kite) Validate() error

func (*Kite) Values

func (k *Kite) Values() []string

Values returns the values of each field in order

type KiteAction

type KiteAction string
const (
	Register   KiteAction = "REGISTER"
	Deregister KiteAction = "DEREGISTER"
)

type KiteEvent

type KiteEvent struct {
	Action KiteAction `json:"action"`
	Kite   Kite       `json:"kite"`

	// Required to connect when Action == Register
	URL   string `json:"url,omitempty"`
	Token string `json:"token,omitempty"`
}

KiteEvent is the struct that is sent as an argument in watchCallback of getKites method of Kontrol.

type KiteWithToken

type KiteWithToken struct {
	Kite  Kite   `json:"kite"`
	URL   string `json:"url"`
	KeyID string `json:"keyId,omitempty"`
	Token string `json:"token"`
}

type KontrolQuery

type KontrolQuery struct {
	Username    string `json:"username"`
	Environment string `json:"environment"`
	Name        string `json:"name"`
	Version     string `json:"version"`
	Region      string `json:"region"`
	Hostname    string `json:"hostname"`
	ID          string `json:"id"`
}

KontrolQuery is a structure of message sent to Kontrol. It is used for querying kites based on the incoming field parameters. Missing fields are not counted during the query (for example if the "version" field is empty, any kite with different version is going to be matched). Order of the fields is from general to specific.

func (KontrolQuery) Fields

func (k KontrolQuery) Fields() map[string]string

type RegisterArgs

type RegisterArgs struct {
	URL  string `json:"url"`
	Kite *Kite  `json:"kite,omitempty"`
	Auth *Auth  `json:"auth,omitempty"`
}

RegisterArgs is used as the function argument to the Kontrol's register method.

type RegisterResult

type RegisterResult struct {
	URL               string `json:"url"`
	HeartbeatInterval int64  `json:"heartbeatInterval"`
	Error             string `json:"err,omitempty"`

	// PublicKey is only available if the public Key of the request is
	// invalid.
	PublicKey string `json:"publicKey,omitempty"`

	// KiteKey is non-empty when caller made a request using kitekey
	// signed by a keypair that was recently deleted.
	//
	// In such case Kontrol is going to create new kite key by signing
	// it with new keys.
	KiteKey string `json:"kiteKey,omitempty"`
}

RegisterResult is a response to Register request from Kite to Kontrol.

type WhoResult

type WhoResult struct {
	Query *KontrolQuery `json:"query"`
}

Jump to

Keyboard shortcuts

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