waspfunctions

package module
v0.0.0-...-480bcf3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

NATS client for all wasp operations

This library allows you to communicate with NATS. It contains all necessary functions to call spider and knot actions.

Some functions use channels for communcation, as returning an array makes no sense since gRPC delivers items one by one. Just be sure you use the channels with go routines.

To create a client, just do:

waspFunctions, err := waspfunctions.Init("hostname:31337",5*time.Second)

Here is a list of functions you can use:

func (c *Client) AddPublicKey(pubkey, owner string, wings []string) error {}
func (c *Client) ListPublicKeys(query string, response chan Pubkey) {}
func (c *Client) DeletePublicKey(query string) error {}

func (c *Client) AddKnot(name, ipport string, wings []string) error {}
func (c *Client) ListKnots(query string, response chan Knot) {}
func (c *Client) DeleteKnot(query string) error {}

func (c *Client) ListWings(query string, response chan Wing) {}
func (c *Client) DeleteWing(query string) error {}

func (c *Client) GetMosquitoes(query string, response chan Mosquito) {}

You can also see examples of how to use this library in the wasp CLI commands.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client holds the connection to the NATS server

func Init

func Init(natsAddress, certPath, natsCreds string, timeout time.Duration) (Client, error)

Init will give you a Client that you can use for other operations You need the hostname, the server certificate and the wasp credentials. The timeout will decide how much wasp operations wait after nats. 5 sec is a good value.

func (*Client) AddPublicKey

func (c *Client) AddPublicKey(pubkey, owner string, wings []string) error

AddPublicKey takes multiple arguments to add a public key

func (*Client) DeleteKnot

func (c *Client) DeleteKnot(query string) error

DeleteKnot will delete a knot based on a string received as input the query must be IP.Port or IP:Port

func (*Client) DeletePublicKey

func (c *Client) DeletePublicKey(query string) error

DeletePublicKey will delete a public key based on a string received as input

func (*Client) DeleteWing

func (c *Client) DeleteWing(query string) error

DeleteWing will delete a knot based on a string received as input. The query must be the name of the wing. This will also cascade to knots and pubkeys.

func (*Client) EditKnot

func (c *Client) EditKnot(name, ipport string, wings []string) error

EditKnot takes multiple arguments to edit a knot ipport must be format 10.0.0.5:3152

func (*Client) GetMosquitoes

func (c *Client) GetMosquitoes(dead bool, query string, response chan Mosquito)

GetMosquitoes will collect all the mosquitoes from all the knots. The "dead" bool means you also want to get the inactive mosquitoes (that don't have a recent Handshake). The query must be in format "knot;pubkey". Only the IP:Port is accepted for the knot in the query. The public key in the query allows you to search by using the public key of the mosquito

func (*Client) ListKnots

func (c *Client) ListKnots(query string, response chan Knot)

ListKnots receives a query and a channel and reponse via channel with all public keys

func (*Client) ListPublicKeys

func (c *Client) ListPublicKeys(query string, response chan Pubkey)

ListPublicKeys receives a query and a channel and reponse via channel with all public keys

func (*Client) ListWings

func (c *Client) ListWings(query string, response chan Wing)

ListWings receives a query and a channel and reponse via channel with all wings The query can be the wing name

func (*Client) SenseKnots

func (c *Client) SenseKnots(ipport string, response chan Knot)

SenseKnots gathers information from all knots that are alive Sense can not know when everythin is done, so it just times out after 2 sec of silence ipport can be used in format IP:Port in order to sense only one knot

type Knot

type Knot struct {
	IPPort        string
	Name          string
	Wings         []string
	Err           error
	BootTimestamp time.Time
	Mosquitoes    int32
}

Knot holds your knot The error allows you to close the response channel this type should only be used via channels, as the spiderweber is based on gRPC

type Mosquito

type Mosquito struct {
	KnotName          string
	KnotIPPort        string
	MosquitoPublicKey string
	MosquitoIP        string
	Err               error
	Handshake         time.Time
}

Mosquito contains all information returned by a spider regarding mosquitoes The error allows you to close the response channel this type should only be used via channels, as the spiderweber is based on gRPC

type Pubkey

type Pubkey struct {
	Pubkey string
	Owner  string
	Wings  []string
	Err    error
}

Pubkey struct hold information about a public key. The error allows you to close the response channel. This type should only be used via channels, as the spiderweber is based on gRPC.

type Wing

type Wing struct {
	Name    string
	Pubkeys []string
	Knots   []string
	Err     error
}

Wing holds a wing

Jump to

Keyboard shortcuts

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