spec

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Argument

type Argument struct {
	Name string
	Type string
}

Argument is an input or output argument of a signature.

func (*Argument) EndType

func (arg *Argument) EndType() string

EndType returns the final part of the type, excluding map, array and pointer markers. map[string]int -> int; []*User -> User; *time.Time -> time.Time

type General

type General struct {
	Host             string `yaml:"host"`
	Description      string `yaml:"description"`
	IntegrationTests bool   `yaml:"integrationTests"`
	OpenAPI          bool   `yaml:"openApi"`
}

General are general properties of the microservice.

func (*General) UnmarshalYAML

func (g *General) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML parses and validates the YAML.

type Handler

type Handler struct {
	Type   string `yaml:"-"`
	Exists bool   `yaml:"-"`

	// Shared
	Signature   *Signature `yaml:"signature"`
	Description string     `yaml:"description"`
	Method      string     `yaml:"method"`
	Path        string     `yaml:"path"`
	Queue       string     `yaml:"queue"`
	OpenAPI     bool       `yaml:"openApi"`

	// Sink
	Event   string `yaml:"event"`
	Source  string `yaml:"source"`
	ForHost string `yaml:"forHost"`

	// Config
	Default    string `yaml:"default"`
	Validation string `yaml:"validation"`
	Callback   bool   `yaml:"callback"`
	Secret     bool   `yaml:"secret"`

	// Metrics
	Kind    string    `json:"kind" yaml:"kind"`
	Alias   string    `json:"alias" yaml:"alias"`
	Buckets []float64 `json:"buckets" yaml:"buckets"`

	// Ticker
	Interval time.Duration `yaml:"interval"`
}

Handler is the spec of a callback handler. Web requests, lifecycle events, config changes, tickers, etc.

func (*Handler) In

func (h *Handler) In() string

In returns the input argument list as a string.

func (*Handler) Incrementable

func (h *Handler) Incrementable() bool

Incrementable indicates if the metric can be incremented.

func (*Handler) MethodWithBody

func (h *Handler) MethodWithBody() bool

MethodWithBody indicates if the HTTP method of the endpoint allows sending a body. "GET", "DELETE", "TRACE", "OPTIONS", "HEAD" do not allow a body.

func (*Handler) Name

func (h *Handler) Name() string

Name of the handler function.

func (*Handler) Observable

func (h *Handler) Observable() bool

Observable indicates if the metric can be observed.

func (*Handler) Out

func (h *Handler) Out() string

In returns the output argument list as a string.

func (*Handler) Port

func (h *Handler) Port() (string, error)

Port returns the port number set in the path.

func (*Handler) SourceSuffix

func (h *Handler) SourceSuffix() string

SourceSuffix returns the last piece of the event source package path, which is expected to point to a microservice.

func (*Handler) UnmarshalYAML

func (h *Handler) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML parses the handler.

type Service

type Service struct {
	Package string `yaml:"-"`

	General   General    `yaml:"general"`
	Configs   []*Handler `yaml:"configs"`
	Metrics   []*Handler `yaml:"metrics"`
	Functions []*Handler `yaml:"functions"`
	Events    []*Handler `yaml:"events"`
	Sinks     []*Handler `yaml:"sinks"`
	Webs      []*Handler `yaml:"webs"`
	Tickers   []*Handler `yaml:"tickers"`

	Types []*Type `yaml:"-"`
	// contains filtered or unexported fields
}

Service is the spec of the microservice parsed from service.yaml.

func (*Service) AllHandlers

func (s *Service) AllHandlers() []*Handler

AllHandlers returns an array holding all handlers of all types.

func (*Service) FullyQualifyTypes

func (s *Service) FullyQualifyTypes()

FullyQualifyTypes prepends the API package name to complex types of function arguments.

func (*Service) PackageSuffix

func (s *Service) PackageSuffix() string

PackageSuffix returns only the last portion of the full package path.

func (*Service) ShorthandTypes

func (s *Service) ShorthandTypes()

ShorthandTypes removed the API package name from complex types of function arguments.

func (*Service) UnmarshalYAML

func (s *Service) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML parses and validates the YAML.

type Signature

type Signature struct {
	OrigString string
	Name       string
	InputArgs  []*Argument
	OutputArgs []*Argument
}

Signature is the spec of a function signature.

func (*Signature) InputArg

func (sig *Signature) InputArg(name string) *Argument

InputArg returns the named input arg, or nil if none exist with this name.

func (*Signature) OutputArg

func (sig *Signature) OutputArg(name string) *Argument

OutputArg returns the named output arg, or nil if none exist with this name.

func (*Signature) TestingT

func (sig *Signature) TestingT() string

TestingT returns "testingT" if "t" conflicts with an argument of the function. Otherwise, "t" is returned.

func (*Signature) UnmarshalYAML

func (sig *Signature) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML parses the signature.

type Type

type Type struct {
	Name    string
	Exists  bool
	Package string
}

Type is a complex type used in a function.

func (*Type) PackageSuffix

func (t *Type) PackageSuffix() string

PackageSuffix returns only the last portion of the full package path.

type Version

type Version struct {
	Package   string
	Version   int    `json:"ver"`
	SHA256    string `json:"sha256"`
	Timestamp string `json:"ts"`
}

Version keeps the versioning information of the code.

func (*Version) PackageSuffix

func (v *Version) PackageSuffix() string

PackageSuffix returns only the last portion of the full package path.

Jump to

Keyboard shortcuts

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