common

package
v1.0.0-beta.8 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: Apache-2.0 Imports: 9 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"
	// Query parameters
	ParamPage        = "page"
	ParamPerPage     = "perPage"
	ParamLimit       = "limit"
	ParamFrom        = "from"
	ParamTo          = "to"
	ParamSort        = "sort"
	ParamDenormalize = "denormalize"
	ParamCount       = "count"

	// 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 ErrorResponse

func ErrorResponse(code int, msg string, w http.ResponseWriter)

ErrorResponse 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 streams

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 AggrConf added in v0.5.0

type AggrConf struct{}

Aggregation config

type Config added in v0.5.0

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

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 struct {
	// Code is the (http) code of the error
	Code int `json:"code"`
	// Message is the (human-readable) error message
	Message string `json:"message"`
}

Error describes an API error (serializable in JSON)

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 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"`
	RetentionPeriods []string       `json:"retentionPeriods"`
}

Registry config

func (RegConf) ConfiguredRetention added in v0.5.2

func (c RegConf) ConfiguredRetention(period string) bool

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 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