Documentation ¶
Index ¶
- Variables
- func All() fx.Option
- func NewSampleHealthChecker() actuator.HealthChecker
- func NewSampleInformer() actuator.Informer
- func NewSampleListener(service *SampleService) pubsub.Subscriber
- type SampleEvent
- type SampleEventExecutor
- type SampleEventMessage
- type SampleHealthChecker
- type SampleInformer
- type SampleListener
- type SampleProperties
- type SampleService
Constants ¶
This section is empty.
Variables ¶
var ( Version = "1.0" CommitHash = "49d52932" BuildTime = "2021/11/30 20:08:12" )
These infos might inject in the build time In order to provide build info, add the following option to bootstrap file golib.BuildInfoOpt(Version, CommitHash, BuildTime)
Functions ¶
func NewSampleHealthChecker ¶
func NewSampleHealthChecker() actuator.HealthChecker
NewSampleHealthChecker Use golib.ProvideHealthChecker(NewSampleHealthChecker) to register a health checker. In this example, the `/actuator/health` endpoint with return:
{ "meta": { "code": 200, "message": "Server is up" }, "data": { "status": "UP", "components": { "sample": { "status": "UP" } } } }
func NewSampleInformer ¶
NewSampleInformer Use golib.ProvideInformer(NewSampleInformer) to register an informer. In this example, the /actuator/info endpoint with return:
{ "meta": { "code": 200, "message": "Successful" }, "data": { "service_name": "Sample Service", "info": { "sample": { "key1": "val1" } } } }
func NewSampleListener ¶
func NewSampleListener(service *SampleService) pubsub.Subscriber
NewSampleListener Use golib.ProvideEventListener(NewSampleListener) to declare a listener
Types ¶
type SampleEvent ¶
type SampleEvent struct {
*event.AbstractEvent
}
func NewSampleEvent ¶
func NewSampleEvent(ctx context.Context, payload *SampleEventMessage) *SampleEvent
NewSampleEvent In order to get more tracing content, inject the request context to your event. Then using pubsub.Publish(NewSampleEvent(ctx, &SampleEventMessage{})) to publish it
func (SampleEvent) String ¶
func (a SampleEvent) String() string
type SampleEventExecutor ¶
type SampleEventExecutor struct { }
func NewSampleEventExecutor ¶
func NewSampleEventExecutor() *SampleEventExecutor
func (SampleEventExecutor) Execute ¶
func (s SampleEventExecutor) Execute(fn func())
type SampleEventMessage ¶
type SampleHealthChecker ¶
type SampleHealthChecker struct { }
func (SampleHealthChecker) Check ¶
func (h SampleHealthChecker) Check(ctx context.Context) actuator.StatusDetails
func (SampleHealthChecker) Component ¶
func (h SampleHealthChecker) Component() string
type SampleInformer ¶
type SampleInformer struct { }
func (SampleInformer) Key ¶
func (s SampleInformer) Key() string
func (SampleInformer) Value ¶
func (s SampleInformer) Value() interface{}
type SampleListener ¶
type SampleListener struct {
// contains filtered or unexported fields
}
func (SampleListener) Handle ¶
func (s SampleListener) Handle(e pubsub.Event)
type SampleProperties ¶
type SampleProperties struct { // We use github.com/go-playground/validator to validate properties Field1 string `validate:"required"` // We use https://github.com/zenthangplus/defaults to set default for properties Field2 int `default:"10"` // We use github.com/mitchellh/mapstructure to bind config to properties Field3 []time.Duration `mapstructure:"field3_new_name"` }
func NewSampleProperties ¶
func NewSampleProperties(loader config.Loader) (*SampleProperties, error)
NewSampleProperties Use golib.ProvideProps(NewSampleProperties) to declare a properties
func (SampleProperties) Prefix ¶
func (s SampleProperties) Prefix() string
Prefix Defines the properties prefix
type SampleService ¶
type SampleService struct {
// contains filtered or unexported fields
}
func NewSampleService ¶
func NewSampleService(httpClient client.ContextualHttpClient) *SampleService
NewSampleService In this case Contextual Http Client is required Use fx.Provide(NewSampleService) to register a service
func (SampleService) DoSomething ¶
func (s SampleService) DoSomething(ctx context.Context) error