Documentation
¶
Index ¶
- type Contract
- func (c *Contract) AddError(err kit.ErrorMessage) *Contract
- func (c *Contract) AddHandler(h ...kit.HandlerFunc) *Contract
- func (c *Contract) AddModifier(m kit.ModifierFunc) *Contract
- func (c *Contract) AddNamedSelector(name string, s kit.RouteSelector) *Contract
- func (c *Contract) AddSelector(s kit.RouteSelector) *Contract
- func (c *Contract) AddWrapper(wrappers ...kit.ContractWrapper) *Contract
- func (c *Contract) Coordinator(f kit.EdgeSelectorFunc) *Contract
- func (c *Contract) In(m kit.Message) *Contract
- func (c *Contract) NamedSelector(name string, s kit.RouteSelector) *Contract
- func (c *Contract) Out(m kit.Message) *Contract
- func (c *Contract) Selector(s kit.RouteSelector) *Contract
- func (c *Contract) SetCoordinator(f kit.EdgeSelectorFunc) *Contract
- func (c *Contract) SetEncoding(enc kit.Encoding) *Contract
- func (c *Contract) SetHandler(h ...kit.HandlerFunc) *Contract
- func (c *Contract) SetInput(m kit.Message) *Contract
- func (c *Contract) SetName(name string) *Contract
- func (c *Contract) SetOutput(m kit.Message) *Contract
- type DTO
- type DTOField
- type DTOFieldTag
- type Error
- type ErrorDTO
- type RESTMethod
- type RPCMethod
- type RouteSelector
- type Service
- func (s *Service) AddContract(contracts ...*Contract) *Service
- func (s *Service) AddError(err kit.ErrorMessage) *Service
- func (s *Service) AddHandler(h ...kit.HandlerFunc) *Service
- func (s *Service) AddWrapper(wrappers ...kit.ServiceWrapper) *Service
- func (s *Service) Generate() kit.Service
- func (s *Service) SetDescription(d string) *Service
- func (s *Service) SetEncoding(enc kit.Encoding) *Service
- func (s *Service) SetVersion(v string) *Service
- func (s *Service) Stub(pkgName string, tags ...string) (*Stub, error)
- type ServiceDesc
- type ServiceDescFunc
- type Stub
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Contract ¶
type Contract struct {
Name string
Encoding kit.Encoding
Handlers []kit.HandlerFunc
Wrappers []kit.ContractWrapper
RouteSelectors []RouteSelector
EdgeSelector kit.EdgeSelectorFunc
Modifiers []kit.ModifierFunc
Input kit.Message
Output kit.Message
PossibleErrors []Error
}
Contract is the description of the kit.Contract you are going to create.
func NewContract ¶
func NewContract() *Contract
func (*Contract) AddError ¶
func (c *Contract) AddError(err kit.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 ...kit.HandlerFunc) *Contract
AddHandler add handler for this contract.
func (*Contract) AddModifier ¶
func (c *Contract) AddModifier(m kit.ModifierFunc) *Contract
AddModifier adds a kit.ModifierFunc for this contract. Modifiers are used to modify the outgoing kit.Envelope just before sending to the client.
func (*Contract) AddNamedSelector ¶
func (c *Contract) AddNamedSelector(name string, s kit.RouteSelector) *Contract
AddNamedSelector adds a kit.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 kit.RouteSelector) *Contract
AddSelector adds a kit.RouteSelector for this contract. Selectors are bundle specific.
func (*Contract) AddWrapper ¶
func (c *Contract) AddWrapper(wrappers ...kit.ContractWrapper) *Contract
AddWrapper adds a kit.ContractWrapper for this contract.
func (*Contract) Coordinator ¶ added in v0.9.15
func (c *Contract) Coordinator(f kit.EdgeSelectorFunc) *Contract
Coordinator is an alias for SetCoordinator
func (*Contract) NamedSelector ¶
func (c *Contract) NamedSelector(name string, s kit.RouteSelector) *Contract
NamedSelector is an alias for AddNamedSelector
func (*Contract) Selector ¶
func (c *Contract) Selector(s kit.RouteSelector) *Contract
Selector is an alias for AddSelector
func (*Contract) SetCoordinator ¶
func (c *Contract) SetCoordinator(f kit.EdgeSelectorFunc) *Contract
SetCoordinator sets a kit.EdgeSelectorFunc for this contract, to coordinate requests to right kit.EdgeServer instance.
func (*Contract) SetEncoding ¶
SetEncoding sets the supported encoding for this contract.
func (*Contract) SetHandler ¶
func (c *Contract) SetHandler(h ...kit.HandlerFunc) *Contract
SetHandler set the handler by replacing the already existing ones.
func (*Contract) SetInput ¶
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.
type DTO ¶
type DTO struct {
// Comments could be used by generators to print some useful information about this DTO
Comments []string
// Name is the name of this DTO struct
Name string
Type string
IsErr bool
Fields []DTOField
}
DTO represents the description of Data Transfer Object of the Stub
type DTOField ¶
type DTOField struct {
// Name of this field
Name string
// Type of this field and if this type is slice or map then it might have one or two
// subtypes
Type string
SubType1 string
SubType2 string
// If this field was an embedded field means fields are coming from an embedded DTO
// If Embedded is TRUE then for sure IsDTO must be TRUE
Embedded bool
IsDTO bool
Tags []DTOFieldTag
}
DTOField represents description of a field of the DTO
type DTOFieldTag ¶
DTOFieldTag represents description of a tag of the DTOField
type ErrorDTO ¶
ErrorDTO represents description of a Data Object Transfer which is used to show an error case.
type RESTMethod ¶
type RESTMethod struct {
Name string
Method string
Path string
Encoding string
Request DTO
Response DTO
PossibleErrors []ErrorDTO
}
RESTMethod represents description of a Contract with kit.RESTRouteSelector.
type RPCMethod ¶
type RPCMethod struct {
Name string
Predicate string
Request DTO
Response DTO
PossibleErrors []ErrorDTO
Encoding string
kit.IncomingRPCContainer
kit.OutgoingRPCContainer
}
RPCMethod represents description of a Contract with kit.RPCRouteSelector
type RouteSelector ¶
type RouteSelector struct {
Name string
Selector kit.RouteSelector
}
type Service ¶
type Service struct {
Name string
Version string
Description string
Encoding kit.Encoding
PossibleErrors []Error
Wrappers []kit.ServiceWrapper
Contracts []Contract
Handlers []kit.HandlerFunc
// contains filtered or unexported fields
}
Service is the description of the kit.Service you are going to create. It then generates a kit.Service by calling Generate method.
func NewService ¶
func (*Service) AddContract ¶
AddContract adds a contract to the service.
func (*Service) AddError ¶
func (s *Service) AddError(err kit.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. NOTE: The auto-generated stub also use these errors to identifies if the response should be considered
as error or successful.
func (*Service) AddHandler ¶
func (s *Service) AddHandler(h ...kit.HandlerFunc) *Service
AddHandler adds handlers to run before and/or after the contract's handlers
func (*Service) AddWrapper ¶
func (s *Service) AddWrapper(wrappers ...kit.ServiceWrapper) *Service
AddWrapper adds service wrappers to the Service description.
func (*Service) SetDescription ¶
func (*Service) SetVersion ¶
type ServiceDesc ¶
type ServiceDesc interface {
Desc() *Service
}
type ServiceDescFunc ¶
type ServiceDescFunc func() *Service
func (ServiceDescFunc) Desc ¶
func (f ServiceDescFunc) Desc() *Service