mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 13:25:40 +00:00
align variable names
This commit is contained in:
@@ -27,11 +27,11 @@ type ExprEnv struct {
|
|||||||
Payload any
|
Payload any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (se *FilterExpr) Process(ctx context.Context, payload any) (any, error) {
|
func (fe *FilterExpr) Process(ctx context.Context, payload any) (any, error) {
|
||||||
|
|
||||||
exprEnv := SafeExprEnv(payload)
|
exprEnv := SafeExprEnv(payload)
|
||||||
|
|
||||||
output, err := expr.Run(se.Program, exprEnv)
|
output, err := expr.Run(fe.Program, exprEnv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -47,8 +47,8 @@ func (se *FilterExpr) Process(ctx context.Context, payload any) (any, error) {
|
|||||||
return payload, nil
|
return payload, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (se *FilterExpr) Type() string {
|
func (fe *FilterExpr) Type() string {
|
||||||
return se.config.Type
|
return fe.config.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type FreeDDecode struct {
|
|||||||
config config.ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fdd *FreeDDecode) Process(ctx context.Context, payload any) (any, error) {
|
func (fd *FreeDDecode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
payloadBytes, ok := GetAnyAs[[]byte](payload)
|
payloadBytes, ok := GetAnyAs[[]byte](payload)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -26,8 +26,8 @@ func (fdd *FreeDDecode) Process(ctx context.Context, payload any) (any, error) {
|
|||||||
return payloadMessage, nil
|
return payloadMessage, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fdd *FreeDDecode) Type() string {
|
func (fd *FreeDDecode) Type() string {
|
||||||
return fdd.config.Type
|
return fd.config.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type FreeDEncode struct {
|
|||||||
config config.ProcessorConfig
|
config config.ProcessorConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fde *FreeDEncode) Process(ctx context.Context, payload any) (any, error) {
|
func (fe *FreeDEncode) Process(ctx context.Context, payload any) (any, error) {
|
||||||
payloadPosition, ok := GetAnyAs[freeD.FreeDPosition](payload)
|
payloadPosition, ok := GetAnyAs[freeD.FreeDPosition](payload)
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -23,8 +23,8 @@ func (fde *FreeDEncode) Process(ctx context.Context, payload any) (any, error) {
|
|||||||
return payloadBytes, nil
|
return payloadBytes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fde *FreeDEncode) Type() string {
|
func (fe *FreeDEncode) Type() string {
|
||||||
return fde.config.Type
|
return fe.config.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -20,24 +20,24 @@ type HTTPResponse struct {
|
|||||||
Body []byte
|
Body []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hre *HTTPResponseCreate) Process(ctx context.Context, payload any) (any, error) {
|
func (hrc *HTTPResponseCreate) Process(ctx context.Context, payload any) (any, error) {
|
||||||
templateData := GetTemplateData(ctx, payload)
|
templateData := GetTemplateData(ctx, payload)
|
||||||
|
|
||||||
var bodyBuffer bytes.Buffer
|
var bodyBuffer bytes.Buffer
|
||||||
err := hre.BodyTmpl.Execute(&bodyBuffer, templateData)
|
err := hrc.BodyTmpl.Execute(&bodyBuffer, templateData)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return HTTPResponse{
|
return HTTPResponse{
|
||||||
Status: hre.Status,
|
Status: hrc.Status,
|
||||||
Body: bodyBuffer.Bytes(),
|
Body: bodyBuffer.Bytes(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hre *HTTPResponseCreate) Type() string {
|
func (hrc *HTTPResponseCreate) Type() string {
|
||||||
return hre.config.Type
|
return hrc.config.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ type RouterOutput struct {
|
|||||||
logger *slog.Logger
|
logger *slog.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dl *RouterOutput) Process(ctx context.Context, payload any) (any, error) {
|
func (ro *RouterOutput) Process(ctx context.Context, payload any) (any, error) {
|
||||||
|
|
||||||
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
router, ok := ctx.Value(common.RouterContextKey).(common.RouteIO)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.New("router.output no router found")
|
return nil, errors.New("router.output no router found")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := router.HandleOutput(ctx, dl.ModuleId, payload)
|
err := router.HandleOutput(ctx, ro.ModuleId, payload)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("router.output failed to send output: %w", err)
|
return nil, fmt.Errorf("router.output failed to send output: %w", err)
|
||||||
@@ -32,8 +32,8 @@ func (dl *RouterOutput) Process(ctx context.Context, payload any) (any, error) {
|
|||||||
return payload, nil
|
return payload, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dl *RouterOutput) Type() string {
|
func (ro *RouterOutput) Type() string {
|
||||||
return dl.config.Type
|
return ro.config.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ type ScriptWASM struct {
|
|||||||
Function string
|
Function string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (se *ScriptWASM) Process(ctx context.Context, payload any) (any, error) {
|
func (sw *ScriptWASM) Process(ctx context.Context, payload any) (any, error) {
|
||||||
|
|
||||||
payloadBytes, ok := GetAnyAs[[]byte](payload)
|
payloadBytes, ok := GetAnyAs[[]byte](payload)
|
||||||
|
|
||||||
@@ -23,13 +23,13 @@ func (se *ScriptWASM) Process(ctx context.Context, payload any) (any, error) {
|
|||||||
return nil, fmt.Errorf("script.wasm can only operator on byte array")
|
return nil, fmt.Errorf("script.wasm can only operator on byte array")
|
||||||
}
|
}
|
||||||
|
|
||||||
program, err := se.Program.Instance(ctx, extism.PluginInstanceConfig{})
|
program, err := sw.Program.Instance(ctx, extism.PluginInstanceConfig{})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, output, err := program.Call(se.Function, payloadBytes)
|
_, output, err := program.Call(sw.Function, payloadBytes)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -38,8 +38,8 @@ func (se *ScriptWASM) Process(ctx context.Context, payload any) (any, error) {
|
|||||||
return output, nil
|
return output, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (se *ScriptWASM) Type() string {
|
func (sw *ScriptWASM) Type() string {
|
||||||
return se.config.Type
|
return sw.config.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ type SipAudioFileResponse struct {
|
|||||||
AudioFile string
|
AudioFile string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scc *SipResponseAudioCreate) Process(ctx context.Context, payload any) (any, error) {
|
func (srac *SipResponseAudioCreate) Process(ctx context.Context, payload any) (any, error) {
|
||||||
|
|
||||||
templateData := GetTemplateData(ctx, payload)
|
templateData := GetTemplateData(ctx, payload)
|
||||||
|
|
||||||
var audioFileBuffer bytes.Buffer
|
var audioFileBuffer bytes.Buffer
|
||||||
err := scc.AudioFile.Execute(&audioFileBuffer, templateData)
|
err := srac.AudioFile.Execute(&audioFileBuffer, templateData)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -36,14 +36,14 @@ func (scc *SipResponseAudioCreate) Process(ctx context.Context, payload any) (an
|
|||||||
audioFileString := audioFileBuffer.String()
|
audioFileString := audioFileBuffer.String()
|
||||||
|
|
||||||
return SipAudioFileResponse{
|
return SipAudioFileResponse{
|
||||||
PreWait: scc.PreWait,
|
PreWait: srac.PreWait,
|
||||||
PostWait: scc.PostWait,
|
PostWait: srac.PostWait,
|
||||||
AudioFile: audioFileString,
|
AudioFile: audioFileString,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scc *SipResponseAudioCreate) Type() string {
|
func (srac *SipResponseAudioCreate) Type() string {
|
||||||
return scc.config.Type
|
return srac.config.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ type SipDTMFResponse struct {
|
|||||||
Digits string
|
Digits string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scc *SipResponseDTMFCreate) Process(ctx context.Context, payload any) (any, error) {
|
func (srdc *SipResponseDTMFCreate) Process(ctx context.Context, payload any) (any, error) {
|
||||||
|
|
||||||
templateData := GetTemplateData(ctx, payload)
|
templateData := GetTemplateData(ctx, payload)
|
||||||
|
|
||||||
var digitsBuffer bytes.Buffer
|
var digitsBuffer bytes.Buffer
|
||||||
err := scc.Digits.Execute(&digitsBuffer, templateData)
|
err := srdc.Digits.Execute(&digitsBuffer, templateData)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -38,19 +38,19 @@ func (scc *SipResponseDTMFCreate) Process(ctx context.Context, payload any) (any
|
|||||||
|
|
||||||
digitsString := digitsBuffer.String()
|
digitsString := digitsBuffer.String()
|
||||||
|
|
||||||
if !scc.validDTMF.MatchString(digitsString) {
|
if !srdc.validDTMF.MatchString(digitsString) {
|
||||||
return nil, errors.New("sip.response.dtmf.create result of digits template contains invalid characters")
|
return nil, errors.New("sip.response.dtmf.create result of digits template contains invalid characters")
|
||||||
}
|
}
|
||||||
|
|
||||||
return SipDTMFResponse{
|
return SipDTMFResponse{
|
||||||
PreWait: scc.PreWait,
|
PreWait: srdc.PreWait,
|
||||||
PostWait: scc.PostWait,
|
PostWait: srdc.PostWait,
|
||||||
Digits: digitsString,
|
Digits: digitsString,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scc *SipResponseDTMFCreate) Type() string {
|
func (srdc *SipResponseDTMFCreate) Type() string {
|
||||||
return scc.config.Type
|
return srdc.config.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -8,18 +8,18 @@ import (
|
|||||||
"github.com/jwetzell/showbridge-go/internal/config"
|
"github.com/jwetzell/showbridge-go/internal/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MetaDelay struct {
|
type TimeSleep struct {
|
||||||
config config.ProcessorConfig
|
config config.ProcessorConfig
|
||||||
Duration time.Duration
|
Duration time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (md *MetaDelay) Process(ctx context.Context, payload any) (any, error) {
|
func (ts *TimeSleep) Process(ctx context.Context, payload any) (any, error) {
|
||||||
time.Sleep(md.Duration)
|
time.Sleep(ts.Duration)
|
||||||
return payload, nil
|
return payload, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (md *MetaDelay) Type() string {
|
func (ts *TimeSleep) Type() string {
|
||||||
return md.config.Type
|
return ts.config.Type
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -33,7 +33,7 @@ func init() {
|
|||||||
return nil, fmt.Errorf("time.sleep duration error: %w", err)
|
return nil, fmt.Errorf("time.sleep duration error: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &MetaDelay{config: config, Duration: time.Millisecond * time.Duration(durationNum)}, nil
|
return &TimeSleep{config: config, Duration: time.Millisecond * time.Duration(durationNum)}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user