api

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIMetaMessageTypeInfo    = "info"
	APIMetaMessageTypeWarning = "warning"
	APIMetaMessageTypeError   = "error"
)
View Source
const (
	SlugServiceAlreadyStarted = "service-already-started"
	SlugServiceStartFailed    = "service-start-failed"
	SlugServiceStopFailed     = "service-stop-failed"
	SlugServiceNotStarted     = "service-not-started"
	SlugServiceNotInitialized = "service-not-initialized"
	SlugServiceReady          = "service-ready"
	SlugServiceNotReady       = "service-not-ready"
	SlugServiceSetParamFailed = "service-set-param-failed"
	SlugJSONDecodeFailed      = "json-decode-failed"
	SlugTypeError             = "type-error"
)
View Source
const ServiceStopTimeout = 5 // Seconds

Variables

View Source
var (
	PacketlossPath = &serviceEndpointPath{basePath: "/packetloss"}
	BandwidthPath  = &serviceEndpointPath{basePath: "/bandwidth"}
	LatencyPath    = &serviceEndpointPath{basePath: "/latency"}
	ServicesPath   = &serviceEndpointPath{basePath: "/services"}
)
View Source
var (
	ErrServiceNotInitialized = errors.New(SlugServiceNotInitialized)
	ErrServiceAlreadyStarted = errors.New(SlugServiceAlreadyStarted)
	ErrServiceNotStarted     = errors.New(SlugServiceNotStarted)
	ErrServiceStopFailed     = errors.New(SlugServiceStopFailed)
	ErrServiceStartFailed    = errors.New(SlugServiceStartFailed)
)

Functions

This section is empty.

Types

type BandwidthStartRequest

type BandwidthStartRequest struct {
	NetworkInterfaceName string `json:"network_interface"`
	Limit                int64  `json:"limit"`
}

type LatencyStartRequest

type LatencyStartRequest struct {
	NetworkInterfaceName string `json:"network_interface"`
	Latency              int64  `json:"latency_ms"`
	Jitter               int64  `json:"jitter_ms"`
}

type MetaMessage

type MetaMessage struct {
	Type    string `json:"type"` // info, warning, error
	Slug    string `json:"slug"`
	Title   string `json:"title"`
	Message string `json:"message"`
}

func (MetaMessage) ToMap

func (m MetaMessage) ToMap() map[string]interface{}

convert a ApiMetaMessage to map[string]interface{}

type PacketLossStartRequest

type PacketLossStartRequest struct {
	NetworkInterfaceName string `json:"network_interface"`
	PacketLossRate       int32  `json:"packet_loss_rate"`
}

type RESTApiV1

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

func NewRESTApiV1

func NewRESTApiV1(productionMode bool, logger *zap.Logger) *RESTApiV1

func (*RESTApiV1) BandwidthStart

func (a *RESTApiV1) BandwidthStart(resp http.ResponseWriter, req *http.Request)

BandwidthStart implements POST /bandwidth/start

func (*RESTApiV1) BandwidthStatus

func (a *RESTApiV1) BandwidthStatus(resp http.ResponseWriter, _ *http.Request)

BandwidthStatus implements GET /bandwidth/status

func (*RESTApiV1) BandwidthStop

func (a *RESTApiV1) BandwidthStop(resp http.ResponseWriter, req *http.Request)

BandwidthStop implements POST /bandwidth/stop

func (*RESTApiV1) GetAllAPIs

func (a *RESTApiV1) GetAllAPIs() []string

func (*RESTApiV1) IndexPage

func (a *RESTApiV1) IndexPage(resp http.ResponseWriter, _ *http.Request)

IndexPage implements GET /

func (*RESTApiV1) LatencyStart

func (a *RESTApiV1) LatencyStart(resp http.ResponseWriter, req *http.Request)

LatencyStart implements POST /latency/start

func (*RESTApiV1) LatencyStatus

func (a *RESTApiV1) LatencyStatus(resp http.ResponseWriter, _ *http.Request)

LatencyStatus implements GET /latency/status

func (*RESTApiV1) LatencyStop

func (a *RESTApiV1) LatencyStop(resp http.ResponseWriter, req *http.Request)

LatencyStop implements POST /latency/stop

func (*RESTApiV1) NetServicesStatus

func (a *RESTApiV1) NetServicesStatus(resp http.ResponseWriter, req *http.Request)

NetServicesStatus implements GET /services/status

func (*RESTApiV1) PacketlossStart

func (a *RESTApiV1) PacketlossStart(resp http.ResponseWriter, req *http.Request)

PacketlossStart implements POST /packetloss/start

func (*RESTApiV1) PacketlossStatus

func (a *RESTApiV1) PacketlossStatus(resp http.ResponseWriter, _ *http.Request)

PacketlossStatus implements GET /packetloss/status

func (*RESTApiV1) PacketlossStop

func (a *RESTApiV1) PacketlossStop(resp http.ResponseWriter, req *http.Request)

PacketlossStop implements POST /packetloss/stop

func (*RESTApiV1) Serve

func (a *RESTApiV1) Serve(addr, originAllowed string) error

func (*RESTApiV1) Shutdown

func (a *RESTApiV1) Shutdown() error

Shutdown stops the API server and all running XDP services.

type ServiceStatus

type ServiceStatus struct {
	Name                 string                 `json:"name"`
	Ready                bool                   `json:"ready"`
	NetworkInterfaceName string                 `json:"network_interface_name"`
	Params               map[string]interface{} `json:"params"` // key:value
}

Jump to

Keyboard shortcuts

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