kite: github.com/koding/kite/protocol Index | Files

package protocol

import "github.com/koding/kite/protocol"

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

Package Files

protocol.go

type Auth Uses

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

type GetKitesArgs Uses

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

type GetKitesResult Uses

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

type GetTokenArgs Uses

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 Uses

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 Uses

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 Uses

func (k *Kite) Query() *KontrolQuery

Query() returns a pointer to KontrolQuery struct.

func (Kite) String Uses

func (k Kite) String() string

func (*Kite) Validate Uses

func (k *Kite) Validate() error

func (*Kite) Values Uses

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

Values returns the values of each field in order

type KiteAction Uses

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

type KiteEvent Uses

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 Uses

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

type KontrolQuery Uses

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 Uses

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

type RegisterArgs Uses

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 Uses

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 Uses

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

Package protocol imports 4 packages (graph) and is imported by 50 packages. Updated 2017-04-07. Refresh now. Tools for package owners.