Skip to content

i-love-flamingo/domainserviceintercept

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Domain Service Intercept

Helper to intercept calls, check for patches, and apply them if necessary.

Supposed to be used in dev, not prod.

example:

package bla

import (
	"flamingo.me/dingo"
	"flamingo.me/domainserviceintercept"
)

type serviceMock struct{}

func (*serviceMock) Configure(injector *dingo.Injector) {
	go dsi.Traceserver()
	injector.BindInterceptor(new(application.Service), dcsIntercepter{})
}

type sInterceptor struct {
	application.Service
}

func (i *sInterceptor) IsDuplicate(ctx context.Context, request *web.Request, order domain.Order) (duplicated bool, err error) {
	dsi.Traceme(ctx, "IsDuplicate", dsi.A{"request": request}, func() { duplicated, err = i.Service.IsDuplicate(ctx, request, order) }, dsi.A{"duplicated": &duplicated, "err": &err}, nil)
	return
}

Example config:

- what: IsDuplicate
  return:
    duplicated: true
  repeat: 2

About

Domain Service Interception and Patching

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages