desc

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2022 License: BSD-3-Clause Imports: 5 Imported by: 4

README

Desc

desc package holds the implementations and definitions of the different descriptors of building blocks of the ronykit framework such as Service, Contract and Stub.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register added in v0.5.4

func Register(descriptions ...ServiceDesc) ronykit.Option

Types

type Contract

type Contract struct {
	Name           string
	Encoding       ronykit.Encoding
	Handlers       []ronykit.HandlerFunc
	Wrappers       []ronykit.ContractWrapper
	RouteSelectors []RouteSelector
	EdgeSelector   ronykit.EdgeSelectorFunc
	Modifiers      []ronykit.Modifier
	Input          ronykit.Message
	Output         ronykit.Message
	PossibleErrors []Error
}

Contract is the description of the ronykit.Contract you are going to create.

func NewContract

func NewContract() *Contract

func (*Contract) AddError added in v0.6.1

func (c *Contract) AddError(err ronykit.ErrorMessage) *Contract

AddError sets the possible errors for this Contract. Using this method is OPTIONAL, which mostly could be used by external tools such as Swagger or any other doc generator tools.

func (*Contract) AddHandler

func (c *Contract) AddHandler(h ...ronykit.HandlerFunc) *Contract

AddHandler add handler for this contract.

func (*Contract) AddModifier

func (c *Contract) AddModifier(m ronykit.Modifier) *Contract

AddModifier adds a ronykit.Modifier for this contract. Modifiers are used to modify the outgoing ronykit.Envelope just before sending to the client.

func (*Contract) AddNamedSelector added in v0.6.0

func (c *Contract) AddNamedSelector(name string, s ronykit.RouteSelector) *Contract

AddNamedSelector adds a ronykit.RouteSelector for this contract, and assign it a unique name. In case of you need to use auto-generated stub.Stub for your service/contract this name will be used in the generated code.

func (*Contract) AddSelector

func (c *Contract) AddSelector(s ronykit.RouteSelector) *Contract

AddSelector adds a ronykit.RouteSelector for this contract. Selectors are bundle specific.

func (*Contract) AddWrapper added in v0.3.1

func (c *Contract) AddWrapper(wrappers ...ronykit.ContractWrapper) *Contract

AddWrapper adds a ronykit.ContractWrapper for this contract.

func (*Contract) In added in v0.6.4

func (c *Contract) In(m ronykit.Message) *Contract

In is an alias for SetInput

func (*Contract) NamedSelector added in v0.6.4

func (c *Contract) NamedSelector(name string, s ronykit.RouteSelector) *Contract

NamedSelector is an alias for AddNamedSelector

func (*Contract) Out added in v0.6.4

func (c *Contract) Out(m ronykit.Message) *Contract

Out is an alias for SetOutput

func (*Contract) Selector added in v0.6.4

func (c *Contract) Selector(s ronykit.RouteSelector) *Contract

Selector is an alias for AddSelector

func (*Contract) SelectorWithName added in v0.6.18

func (c *Contract) SelectorWithName(name string, s ronykit.RouteSelector) *Contract

SelectorWithName is an alias for AddNamedSelector

func (*Contract) SetCoordinator added in v0.4.7

func (c *Contract) SetCoordinator(f ronykit.EdgeSelectorFunc) *Contract

SetCoordinator sets a ronykit.EdgeSelectorFunc for this contract, to coordinate requests to right ronykit.EdgeServer instance.

func (*Contract) SetEncoding added in v0.3.5

func (c *Contract) SetEncoding(enc ronykit.Encoding) *Contract

SetEncoding sets the supported encoding for this contract.

func (*Contract) SetHandler

func (c *Contract) SetHandler(h ...ronykit.HandlerFunc) *Contract

SetHandler set the handler by replacing the already existing ones.

func (*Contract) SetInput

func (c *Contract) SetInput(m ronykit.Message) *Contract

SetInput sets the accepting message for this Contract. Contracts are bound to one input message. In some odd cases if you need to handle multiple input messages, then you SHOULD create multiple contracts but with same handlers and/or selectors.

func (*Contract) SetName

func (c *Contract) SetName(name string) *Contract

SetName sets the name of the Contract c, it MUST be unique per Service. However, it has no operation effect only is helpful with some other tools such as monitoring, logging or tracing tools to identity it.

func (*Contract) SetOutput

func (c *Contract) SetOutput(m ronykit.Message) *Contract

SetOutput sets the outgoing message for this Contract. This is an OPTIONAL parameter, which mostly could be used by external tools such as Swagger or any other doc generator tools.

type DTO added in v0.6.0

type DTO struct {
	Comments []string
	Name     string
	Type     string
	IsErr    bool
	Fields   []DTOField
}

DTO represents the description of Data Object Transfer of the Stub

func (DTO) CodeField added in v0.6.5

func (dto DTO) CodeField() string

func (DTO) ItemField added in v0.6.5

func (dto DTO) ItemField() string

type DTOField added in v0.6.0

type DTOField struct {
	Name     string
	Type     string
	Embedded bool
	IsDTO    bool
	Tags     []DTOFieldTag
}

DTOField represents description of a field of the DTO

type DTOFieldTag added in v0.6.0

type DTOFieldTag struct {
	Name  string
	Value string
}

DTOFieldTag represents description of a tag of the DTOField

type Error added in v0.3.3

type Error struct {
	Code    int
	Item    string
	Message ronykit.Message
}

type ErrorDTO added in v0.6.2

type ErrorDTO struct {
	Code int
	Item string
	DTO  DTO
}

ErrorDTO represents description of a Data Object Transfer which is used to show an error case.

type RESTMethod added in v0.6.0

type RESTMethod struct {
	Name           string
	Method         string
	Path           string
	Encoding       string
	Request        DTO
	Response       DTO
	PossibleErrors []ErrorDTO
}

RESTMethod represents description of a Contract with ronykit.RESTRouteSelector.

type RPCMethod added in v0.6.0

type RPCMethod struct {
	Name           string
	Predicate      string
	Request        DTO
	Response       DTO
	PossibleErrors []ErrorDTO
	Encoding       string
	ronykit.IncomingRPCContainer
	ronykit.OutgoingRPCContainer
}

RPCMethod represents description of a Contract with ronykit.RPCRouteSelector

type RouteSelector added in v0.6.4

type RouteSelector struct {
	Name     string
	Selector ronykit.RouteSelector
}

type Service

type Service struct {
	Name           string
	Version        string
	Description    string
	Encoding       ronykit.Encoding
	PossibleErrors []Error
	Wrappers       []ronykit.ServiceWrapper
	Contracts      []Contract
	Handlers       []ronykit.HandlerFunc
	// contains filtered or unexported fields
}

Service is the description of the ronykit.Service you are going to create. It then generates a ronykit.Service by calling Generate method.

func NewService

func NewService(name string) *Service

func (*Service) AddContract

func (s *Service) AddContract(contracts ...*Contract) *Service

AddContract adds a contract to the service.

func (*Service) AddError added in v0.6.1

func (s *Service) AddError(err ronykit.ErrorMessage) *Service

AddError sets the possible errors for all the Contracts of this Service. Using this method is OPTIONAL, which mostly could be used by external tools such as Swagger or any other doc generator tools.

func (*Service) AddHandler added in v0.6.23

func (s *Service) AddHandler(h ...ronykit.HandlerFunc) *Service

AddHandler adds handlers to run before and/or after the contract's handlers

func (*Service) AddPreHandler added in v0.3.4

func (s *Service) AddPreHandler(h ...ronykit.HandlerFunc) *Service

AddPreHandler Deprecated use AddHandler instead.

func (*Service) AddWrapper

func (s *Service) AddWrapper(wrappers ...ronykit.ServiceWrapper) *Service

AddWrapper adds service wrappers to the Service description.

func (Service) Generate

func (s Service) Generate() ronykit.Service

Generate generates the ronykit.Service

func (*Service) SetDescription added in v0.3.4

func (s *Service) SetDescription(d string) *Service

func (*Service) SetEncoding added in v0.3.5

func (s *Service) SetEncoding(enc ronykit.Encoding) *Service

func (*Service) SetVersion added in v0.3.4

func (s *Service) SetVersion(v string) *Service

func (Service) Stub added in v0.6.0

func (s Service) Stub(pkgName string, tags ...string) (*Stub, error)

Stub returns the Stub, which describes the stub specification and could be used to auto-generate stub for this service.

type ServiceDesc added in v0.6.0

type ServiceDesc interface {
	Desc() *Service
}

type ServiceDescFunc added in v0.6.4

type ServiceDescFunc func() *Service

func (ServiceDescFunc) Desc added in v0.6.4

func (f ServiceDescFunc) Desc() *Service

type Stub added in v0.6.0

type Stub struct {
	Pkg   string
	Name  string
	DTOs  map[string]DTO
	RESTs []RESTMethod
	RPCs  []RPCMethod
	// contains filtered or unexported fields
}

Stub represents description of a stub of the service described by Service descriptor.

func (*Stub) Tags added in v0.6.3

func (d *Stub) Tags() []string

Jump to

Keyboard shortcuts

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