scaff

package
v0.0.0-...-b11ff8e Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ScaffoldContextHelper

func ScaffoldContextHelper(context any, ctx *ScaffoldContext, handler func(any, *ScaffoldContext, micro.Request)) micro.Handler

Types

type ScaffoldContext

type ScaffoldContext struct {
	Nats        *mq.Nats
	ServiceInfo micro.Info
}

func (*ScaffoldContext) DecodeRequest

func (s *ScaffoldContext) DecodeRequest(req micro.Request, result any) error

DecodeRequest convenience function for decoding structure data

func (*ScaffoldContext) Init

func (s *ScaffoldContext) Init(nats *mq.Nats, serviceInfo micro.Info) *ScaffoldContext

Init create the scaffold context

func (*ScaffoldContext) PublishError

func (s *ScaffoldContext) PublishError(req micro.Request, err error)

PublishError convenience function to publish errors

type ScaffoldTask

type ScaffoldTask struct {
	Interval time.Duration
	Handler  func(context any, scaffoldContext *ScaffoldContext)
	LastRun  time.Time
	Synced   bool
	// contains filtered or unexported fields
}

type ServiceScaffold

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

func (*ServiceScaffold) AddHandler

func (s *ServiceScaffold) AddHandler(context any, subject string,
	handler func(context any, scaffoldContext *ScaffoldContext, request micro.Request)) error

AddHandler adds the new handler to the scaff

func (*ServiceScaffold) AddRepeatTask

func (s *ServiceScaffold) AddRepeatTask(context any, interval string,
	taskHandler func(context any, scaffoldContext *ScaffoldContext)) error

AddRepeatTask adds a task that is routinely called at specified duration interval is a specific time string ex. 30s 1m 5m 1h

func (*ServiceScaffold) Init

func (s *ServiceScaffold) Init(serviceName string, version string, description string) (*ServiceScaffold, error)

Init create a service scaffold

func (*ServiceScaffold) IsRunning

func (s *ServiceScaffold) IsRunning() bool

func (*ServiceScaffold) SendMessage

func (s *ServiceScaffold) SendMessage(subject string, data any) error

func (*ServiceScaffold) SendRequest

func (s *ServiceScaffold) SendRequest(subject string, data any, result any) error

func (*ServiceScaffold) ServiceID

func (s *ServiceScaffold) ServiceID() string

func (*ServiceScaffold) Start

func (s *ServiceScaffold) Start() error

Start the service with a context, Note: context can be any structure or data for use by the handlers

func (*ServiceScaffold) Stop

func (s *ServiceScaffold) Stop() error

Jump to

Keyboard shortcuts

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