Documentation
¶
Index ¶
- func IsResponseValid(mappedResp MappedResponses, response interface{}, code int) bool
- type ConfigurableService
- type DatabaseConfigurable
- type HttpEncoder
- type MappedResponses
- type OpenAPICompatible
- type OptionsConfigurable
- type RegisteredResponse
- type ResponseType
- type ResponseTypes
- type Service
- type UpdatableWrappedService
- type UsingConfig
- type UsingDB
- type Wrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsResponseValid ¶
func IsResponseValid(mappedResp MappedResponses, response interface{}, code int) bool
IsResponseValid
check if a service response is valid based on its OpenAPICompatible implementation
Types ¶
type ConfigurableService ¶
type ConfigurableService interface { GetConfig() interface{} SetConfig(config interface{}) }
ConfigurableService
The GetConfig method should return a configuration object that can be used by business logic.
Recommended to just embed the UsingConfig struct into your service or embed BasicService.
type DatabaseConfigurable ¶
DatabaseConfigurable
A service implementing this interface is able to use the database supplied by config.WithDatabase within its service business logic using GetDatabase member. The database will be supplied from the common configuration.
Recommended to just embed the UsingDB struct to your service unless a special wiring is needed.
type HttpEncoder ¶
type HttpEncoder interface {
Encode(ctx context.Context, w http.ResponseWriter, response interface{}) error
}
HttpEncoder
Objects that implement this interface will pass the defined function to the encoder part of the go-kit route definition
type MappedResponses ¶
type MappedResponses []RegisteredResponse
MappedResponses
type alias: []RegisteredResponse
func RegisterResponses ¶
func RegisterResponses(types []ResponseType) MappedResponses
RegisterResponses
helper method used to generate the proper return value for ExpectedResponses of the OpenAPICompatible interface
type OpenAPICompatible ¶
type OpenAPICompatible interface { Service ExpectedResponses() MappedResponses }
OpenAPICompatible
Indicates that the service adheres to the OpenAPI standard. ExpectedResponses are all of the responses that the service will be expected to generate. If Strict mode is enabled (see config.Config) then the ExpectedResponses list will be used to validate all service execution.
type OptionsConfigurable ¶
type OptionsConfigurable interface { // ServerOptions // // Returns a list of request options that are only applicable for a single service. These are read when the service // is first created and used throughout the service lifetime ServerOptions() []kitDefaults.ServerOption }
OptionsConfigurable
Services that implement this interface are responsible for a unique set of custom options that are applied before each service call. These options are unique to the service
type RegisteredResponse ¶
RegisteredResponse
Each RegisteredResponse is an expected response from the given OpenAPICompatible service.
type ResponseType ¶
type ResponseType struct { Type interface{} Code int }
ResponseType
slimmed down schema used to register service response types
type Service ¶
Service
Business logic for an endpoint. Execute satisfies the endpoint.Endpoint interface.
type UpdatableWrappedService ¶
type UpdatableWrappedService interface { // GetNext // // Retrieves the wrapped service. GetNext() Service // UpdateNext // // Updates the wrapped service. When called, this will update the wrapped service UpdateNext(nxt Service) }
UpdatableWrappedService
This interface is for services that wrap other services.
type UsingConfig ¶
type UsingConfig struct {
// contains filtered or unexported fields
}
UsingConfig
Embed this into any Service struct in order to gain the ability to reference the custom configuration object. Suggest creating a shared wrapper function to convert the empty interface to a concrete type.
func ToConfig(service ConfigurableService) *viper.Viper { return service.GetConfig().(*viper.Viper) }
func (UsingConfig) GetConfig ¶
func (u UsingConfig) GetConfig() interface{}
GetConfig
Returns the configuration associated with the ConfigurableService. Suggest creating a shared wrapper function to convert the empty interface to a concrete type.
func ToConfig(service ConfigurableService) *viper.Viper { return service.GetConfig().(*viper.Viper) }
func (*UsingConfig) SetConfig ¶
func (u *UsingConfig) SetConfig(config interface{})
SetConfig
Sets the configuration associated with the ConfigurableService ¶
This may come in handy when using gkBoot.Wrapper delegates in your private business logic. Otherwise, the gkBoot wiring finds this and sets the config automatically.
type UsingDB ¶
type UsingDB struct {
// contains filtered or unexported fields
}
UsingDB
Embed this into any Service struct in order to gain the ability to reference the custom sql database object.
func (UsingDB) GetDatabase ¶
GetDatabase
This is the workhorse for the UsingDB embed and returns the saved db instance.
func (*UsingDB) SetDatabase ¶
SetDatabase
This member function may be very useful for template delegates using the wrapper pattern. When injecting delegates to your private service fields, check for DatabaseConfigurable and use this to set a passed database from the parent to the delegate (for example).