webhook

package
v0.0.0-...-388d6c9 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package webhook implemented the webhook trigger and handler convertor.go implements the conversion between entity and po

Package webhook implemented the webhook trigger and handler entity.go implements the webhook template

Package webhook implemented the webhook trigger and handler handler.go implements the grpc handler of webhook trigger

Package webhook implemented the webhook trigger and handler template.go implements the webhook template

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	pb.UnimplementedWebhookTriggerServiceServer
	// contains filtered or unexported fields
}

Handler is the grpc handler of webhook trigger

func NewHandler

func NewHandler(t *Trigger) *Handler

NewHandler create a new handler

func (*Handler) Call

Call handler webhook

func (*Handler) FindOneByID

FindOneByID find one by id

func (*Handler) PageQueryTemplate

func (h *Handler) PageQueryTemplate(ctx context.Context,
	req *pb.PageQueryTemplateRequest) (*pb.WebhookPageQueryResponse, error)

PageQueryTemplate page query

func (*Handler) Register

Register register a webhook trigger template

func (*Handler) UpdateStatus

func (h *Handler) UpdateStatus(ctx context.Context, req *pb.UpdateStatusRequest) (*pb.UpdateStatusResponse, error)

UpdateStatus update the status of trigger

type Trigger

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

Trigger is the webhook trigger

func NewTrigger

func NewTrigger(db *mysql.Client, client broker.SchedulerServiceClient, prefix string) *Trigger

NewTrigger create a webhook trigger

func (*Trigger) Call

func (t *Trigger) Call(ctx context.Context, id uint) (string, error)

Call trigger a webhook by id

func (*Trigger) FindByID

func (t *Trigger) FindByID(ctx context.Context, id uint) (*TriggerTemplate, error)

FindByID find webhook template by id

func (*Trigger) PageQuery

func (t *Trigger) PageQuery(ctx context.Context, p *constants.PageQuery,
	status pb.TriggerStatus) ([]*TriggerTemplate, int64, error)

PageQuery page query webhook templates

func (*Trigger) Register

func (t *Trigger) Register(ctx context.Context, temp *TriggerTemplate) error

Register create a webhook template

func (*Trigger) UpdateStatus

func (t *Trigger) UpdateStatus(ctx context.Context, id uint, status pb.TriggerStatus) (int64, error)

UpdateStatus update webhook template status

type TriggerTemplate

type TriggerTemplate struct {
	// ID is the id of the template
	ID uint

	// Topic the message topic
	Topic string `validate:"required"`
	// Payload the message payload
	Payload []byte `validate:"required"`
	// Message DeliverAfter time (Seconds)
	DeliverAfter uint64 `json:"deliver_after" validate:"required"`

	// LoopedTimes already loop times
	LoopedTimes uint64 `json:"looped_times"`

	// ExceptedEndTime Excepted Trigger end time, if it is 0, it means that it will not end.
	ExceptedEndTime time.Time `json:"excepted_end_time"`
	// ExceptedLoopTimes except loop times
	ExceptedLoopTimes uint64 `json:"excepted_loop_times"`

	// Status the CronTriggerTemplate status: enable offline
	Status pb.TriggerStatus `json:"status" validate:"required"`
}

TriggerTemplate is the webhook template

Jump to

Keyboard shortcuts

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