eventsvc

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 7 Imported by: 0

README

eventsvc

This example illustrates how to generate code for Event subscribers.

Generate the code

$ go generate

Test the code

$ go run cmd/main.go
Received event #1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeEndpointOfEventCreated

func MakeEndpointOfEventCreated(s Service) endpoint.Endpoint

MakeEndpointOfEventCreated creates the endpoint for s.EventCreated.

func NewEventHandler

func NewEventHandler(svc Service, codecs eventcodec.Codecs) eventpubsub.Handler

func ValidateEventCreatedRequest

func ValidateEventCreatedRequest(newSchema func(*EventCreatedRequest) validating.Schema) httpoption.Validator

ValidateEventCreatedRequest creates a validator for EventCreatedRequest.

Types

type EventCreatedRequest

type EventCreatedRequest struct {
	Id int `json:"id"`
}

type EventCreatedResponse

type EventCreatedResponse struct {
	Err error `json:"-"`
}

func (*EventCreatedResponse) Body

func (r *EventCreatedResponse) Body() interface{}

func (*EventCreatedResponse) Failed

func (r *EventCreatedResponse) Failed() error

Failed implements endpoint.Failer.

type EventPublisher

type EventPublisher struct {
	// contains filtered or unexported fields
}

EventPublisher implements Service on the publisher side.

EventPublisher should only be used in limited scenarios where only one subscriber is involved and the publisher depends on the interface provided by the subscriber.

In typical use cases of the publish-subscribe pattern - many subscribers are involved and the publisher knows nothing about the subscribers - you should just send the event in the way it should be.

func NewEventPublisher

func NewEventPublisher(publisher eventpubsub.Publisher, codecs eventcodec.Codecs) *EventPublisher

func (*EventPublisher) EventCreated

func (p *EventPublisher) EventCreated(ctx context.Context, id int) (err error)

type Service

type Service interface {
	//kun:event type=created
	EventCreated(ctx context.Context, id int) error
}

Service is used for handling events.

type Subscriber

type Subscriber struct{}

func (*Subscriber) EventCreated

func (s *Subscriber) EventCreated(ctx context.Context, id int) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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