common

package
v1.0.0-beta.11 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2020 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// IDSeparator is used for separation of IDs in the BrokerURL
	IDSeparator = ","

	// Location of APIs
	RegistryAPILoc = "/registry"
	DataAPILoc     = "/data"
	// QueryPage parameters
	ParamPage        = "page"
	ParamPerPage     = "perPage"
	ParamLimit       = "limit"
	ParamFrom        = "from"
	ParamTo          = "to"
	ParamSort        = "sort"
	ParamDenormalize = "denormalize"
	ParamCount       = "count"
	ParamAggr        = "aggr"
	ParamWindow      = "window"

	// Values for ParamSort
	Asc  = "asc"  // ascending
	Desc = "desc" // descending
	//values for auth providers
	Keycloak = "keycloak"

	DNSSDServiceType = "_linksmart-hds._tcp"
)

Variables

View Source
var (
	// APIVersion defines the API version
	APIVersion string

	// Default MIME type for all responses
	DefaultMIMEType string
)

Functions

func HttpErrorResponse

func HttpErrorResponse(err Error, w http.ResponseWriter)

HttpErrorResponse writes error to HTTP ResponseWriter

func ParsePagingParams

func ParsePagingParams(page, perPage string, maxPerPage int) (int, int, error)

func PerItemPagination

func PerItemPagination(_qLimit, _page, _perPage, _numOfSrcs int) (perItems []int, offsets []int)

Calculate perItem and offset given the page, perPage, limit, and number of time series

func SetVersion

func SetVersion(version string)

func SupportedAggregate

func SupportedAggregate(a string) bool

SupportedAggregate validates an aggregate

func SupportedPeriod added in v0.5.0

func SupportedPeriod(p string) bool

SupportedPeriod validates a period

func SupportedPeriods added in v0.6.1

func SupportedPeriods() []string

SupportedPeriods returns supported periods

func ValidatePagingParams

func ValidatePagingParams(page, perPage, maxPerPage int) error

func ValidatePerItemLimit

func ValidatePerItemLimit(_qLimit, _perPage, _numOfSrcs int) error

Check if the parameters match the criteria required by PerItemPagination function

Types

type BadRequestError

type BadRequestError struct{ S string }

Bad Request

func (*BadRequestError) Error

func (e *BadRequestError) Error() string

func (*BadRequestError) GrpcStatus

func (e *BadRequestError) GrpcStatus() codes.Code

func (*BadRequestError) HttpStatus

func (e *BadRequestError) HttpStatus() int

func (*BadRequestError) Title

func (e *BadRequestError) Title() string

type CertData

type CertData struct {
	Country            string `json:"country"`
	Province           string `json:"province"`
	Locality           string `json:"locality"`
	Organization       string `json:"organization"`
	OrganizationalUnit string `json:"organizationalUnit"`
	CommonName         string `json:"commonName"`
	//DNSNames are Subject Alternative Names (SAN)
	DNSNames    string `json:"dnsNames"`
	IPAddresses string `json:"ipAddresses"`
}

type Config added in v0.5.0

type Config struct {
	// Service ID
	ServiceID string `json:"serviceID"`
	// HDS API addr
	HTTP HTTPConf `json:"http"`
	// HDS GRPC API addr
	GRPC GRPCConf `json:"grpc"`
	//DNS service discovery
	DnssdEnabled bool `json:"dnssdEnabled"`
	//DNS-SD description
	Description string `json:"description"`
	// Registry API Config
	Registry RegConf `json:"registry"`
	// Data API Config
	Data DataConf `json:"data"`
	// LinkSmart Service Catalog registration config
	ServiceCatalog ServiceCatalogConf `json:"serviceCatalog"`
	// Auth config
	Auth validator.Conf `json:"auth"`
	//PKI config
	PKI PKI `json:pki`
}

func (Config) String

func (c Config) String() string

type ConflictError

type ConflictError struct{ S string }

Conflict (non-unique id, assignment to read-only data)

func (*ConflictError) Error

func (e *ConflictError) Error() string

func (*ConflictError) GrpcStatus

func (e *ConflictError) GrpcStatus() codes.Code

func (*ConflictError) HttpStatus

func (e *ConflictError) HttpStatus() int

func (*ConflictError) Title

func (e *ConflictError) Title() string

type DataBackendConf added in v0.5.0

type DataBackendConf struct {
	Type string `json:"type"`
	DSN  string `json:"dsn"`
}

Data backend config

type DataConf added in v0.5.0

type DataConf struct {
	Backend DataBackendConf `json:"backend"`
	// RetentionPeriods is deprecated, will be removed from v0.6.0. Use registry.retentionPeriods instead.
	RetentionPeriods []string `json:"retentionPeriods"`
	AutoRegistration bool     `json:"autoRegistration"`
}

Data config

type Error

type Error interface {
	error
	HttpStatus() int
	GrpcStatus() codes.Code
	Title() string
}

type GRPCConf

type GRPCConf struct {
	Enabled  bool   `json:"enabled"`
	BindAddr string `json:"bindAddr"`
	BindPort uint16 `json:"bindPort"`
}

GRPC config

type HTTPConf added in v0.5.0

type HTTPConf struct {
	PublicEndpoint string `json:"publicEndpoint"`
	BindAddr       string `json:"bindAddr"`
	BindPort       uint16 `json:"bindPort"`
}

HTTP config

type InternalError

type InternalError struct{ S string }

Not Found

func (*InternalError) Error

func (e *InternalError) Error() string

func (*InternalError) GrpcStatus

func (e *InternalError) GrpcStatus() codes.Code

func (*InternalError) HttpStatus

func (e *InternalError) HttpStatus() int

func (*InternalError) Title

func (e *InternalError) Title() string

type NotFoundError

type NotFoundError struct{ S string }

Not Found

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

func (*NotFoundError) GrpcStatus

func (e *NotFoundError) GrpcStatus() codes.Code

func (*NotFoundError) HttpStatus

func (e *NotFoundError) HttpStatus() int

func (*NotFoundError) Title

func (e *NotFoundError) Title() string

type PKI

type PKI struct {
	CaCert     string `json:"caCert"`
	CaKey      string `json:"caKey"`
	ServerCert string `json:"serverCert"`
	ServerKey  string `json:"serverKey"`
	// Data needed for CA or server certificate
	CertData CertData `json:"certData"`
}

Certificate authority and Certificate and

type RegBackendConf added in v0.5.0

type RegBackendConf struct {
	Type string `json:"type"`
	DSN  string `json:"dsn"`
}

Registry backend config

type RegConf added in v0.5.0

type RegConf struct {
	Backend RegBackendConf `json:"backend"`
}

Registry config

type ServiceCatalogConf added in v0.5.0

type ServiceCatalogConf struct {
	Enabled  bool          `json:"enabled"`
	Discover bool          `json:"discover"`
	Endpoint string        `json:"endpoint"`
	TTL      uint          `json:"ttl"`
	Auth     obtainer.Conf `json:"auth"`
}

LinkSmart Service Catalog registration config

type UnsupportedMediaTypeError

type UnsupportedMediaTypeError struct{ S string }

Deadline Exceeded Error

func (*UnsupportedMediaTypeError) Error

func (e *UnsupportedMediaTypeError) Error() string

func (*UnsupportedMediaTypeError) GrpcStatus

func (e *UnsupportedMediaTypeError) GrpcStatus() codes.Code

func (*UnsupportedMediaTypeError) HttpStatus

func (e *UnsupportedMediaTypeError) HttpStatus() int

func (*UnsupportedMediaTypeError) Title

func (e *UnsupportedMediaTypeError) Title() string

type WebConfig added in v0.5.0

type WebConfig struct {
	BindAddr  string `json:"bindAddr"`
	BindPort  uint16 `json:"bindPort"`
	StaticDir string `json:"staticDir"`
}

Web GUI Config

Jump to

Keyboard shortcuts

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