example

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 All added in v1.0.1

func All() fx.Option

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

func NewSampleInformer() actuator.Informer

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 SampleEventMessage struct {
	Field1 string
	Field2 string
}

type SampleHealthChecker

type SampleHealthChecker struct {
}

func (SampleHealthChecker) Check

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)

func (SampleListener) Supports

func (s SampleListener) Supports(e pubsub.Event) bool

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

Jump to

Keyboard shortcuts

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