• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rom8726 / floxy / 18849131494

27 Oct 2025 04:51PM UTC coverage: 37.768% (-5.3%) from 43.091%
18849131494

push

github

rom8726
Notification Engine plugin implemented.

0 of 160 new or added lines in 7 files covered. (0.0%)

1410 existing lines in 3 files now uncovered.

2592 of 6863 relevant lines covered (37.77%)

32.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/plugins/engine/audit/plugin.go
1
package audit
2

3
import (
4
        "context"
5
        "encoding/json"
6
        "time"
7

8
        "github.com/rom8726/floxy"
9
)
10

11
var _ floxy.Plugin = (*AuditPlugin)(nil)
12

13
type AuditLogEntry struct {
14
        Timestamp  time.Time       `json:"timestamp"`
15
        EventType  string          `json:"event_type"`
16
        InstanceID int64           `json:"instance_id"`
17
        WorkflowID string          `json:"workflow_id"`
18
        StepID     *int64          `json:"step_id,omitempty"`
19
        StepName   string          `json:"step_name,omitempty"`
20
        Status     string          `json:"status"`
21
        Error      string          `json:"error,omitempty"`
22
        Duration   *time.Duration  `json:"duration,omitempty"`
23
        Metadata   json.RawMessage `json:"metadata,omitempty"`
24
}
25

26
type Writer interface {
27
        Write(ctx context.Context, entry *AuditLogEntry) error
28
}
29

30
type AuditPlugin struct {
31
        floxy.BasePlugin
32

33
        writer Writer
34
}
35

36
func New(writer Writer) *AuditPlugin {
×
37
        return &AuditPlugin{
×
38
                BasePlugin: floxy.NewBasePlugin("audit", floxy.PriorityNormal),
×
39
                writer:     writer,
×
40
        }
×
41
}
×
42

43
func (p *AuditPlugin) OnWorkflowFailed(ctx context.Context, instance *floxy.WorkflowInstance) error {
×
44
        var errorMsg string
×
45
        if instance.Error != nil {
×
46
                errorMsg = *instance.Error
×
47
        }
×
48

49
        entry := AuditLogEntry{
×
50
                Timestamp:  time.Now(),
×
51
                EventType:  "workflow_failed",
×
52
                InstanceID: instance.ID,
×
53
                WorkflowID: instance.WorkflowID,
×
54
                Status:     string(instance.Status),
×
55
                Error:      errorMsg,
×
56
                Metadata:   instance.Output,
×
57
        }
×
58

×
59
        return p.logEvent(ctx, &entry)
×
60
}
61

NEW
62
func (p *AuditPlugin) OnWorkflowStart(ctx context.Context, instance *floxy.WorkflowInstance) error {
×
NEW
63
        entry := AuditLogEntry{
×
NEW
64
                Timestamp:  time.Now(),
×
NEW
65
                EventType:  "workflow_start",
×
NEW
66
                InstanceID: instance.ID,
×
NEW
67
                WorkflowID: instance.WorkflowID,
×
NEW
68
                Status:     string(instance.Status),
×
NEW
69
                Metadata:   instance.Input,
×
NEW
70
        }
×
NEW
71

×
NEW
72
        return p.logEvent(ctx, &entry)
×
NEW
73
}
×
74

NEW
75
func (p *AuditPlugin) OnWorkflowComplete(ctx context.Context, instance *floxy.WorkflowInstance) error {
×
NEW
76
        entry := AuditLogEntry{
×
NEW
77
                Timestamp:  time.Now(),
×
NEW
78
                EventType:  "workflow_complete",
×
NEW
79
                InstanceID: instance.ID,
×
NEW
80
                WorkflowID: instance.WorkflowID,
×
NEW
81
                Status:     string(instance.Status),
×
NEW
82
                Metadata:   instance.Output,
×
NEW
83
        }
×
NEW
84

×
NEW
85
        return p.logEvent(ctx, &entry)
×
NEW
86
}
×
87

88
func (p *AuditPlugin) OnStepStart(
89
        ctx context.Context,
90
        instance *floxy.WorkflowInstance,
91
        step *floxy.WorkflowStep,
NEW
92
) error {
×
93
        entry := AuditLogEntry{
×
94
                Timestamp:  time.Now(),
×
95
                EventType:  "step_start",
×
96
                InstanceID: step.InstanceID,
×
NEW
97
                WorkflowID: instance.WorkflowID,
×
98
                StepID:     &step.ID,
×
99
                StepName:   step.StepName,
×
100
                Status:     string(step.Status),
×
101
                Metadata:   step.Input,
×
102
        }
×
103

×
104
        return p.logEvent(ctx, &entry)
×
105
}
×
106

107
func (p *AuditPlugin) OnStepFailed(
108
        ctx context.Context,
109
        instance *floxy.WorkflowInstance,
110
        step *floxy.WorkflowStep,
111
        err error,
NEW
112
) error {
×
113
        var errorMsg string
×
114
        if step.Error != nil {
×
115
                errorMsg = *step.Error
×
116
        } else if err != nil {
×
117
                errorMsg = err.Error()
×
118
        }
×
119

120
        entry := AuditLogEntry{
×
121
                Timestamp:  time.Now(),
×
122
                EventType:  "step_failed",
×
123
                InstanceID: step.InstanceID,
×
NEW
124
                WorkflowID: instance.WorkflowID,
×
125
                StepID:     &step.ID,
×
126
                StepName:   step.StepName,
×
127
                Status:     string(step.Status),
×
128
                Error:      errorMsg,
×
129
                Metadata:   step.Input,
×
130
        }
×
131

×
132
        return p.logEvent(ctx, &entry)
×
133
}
134

NEW
135
func (p *AuditPlugin) OnStepComplete(ctx context.Context, instance *floxy.WorkflowInstance, step *floxy.WorkflowStep) error {
×
136
        entry := AuditLogEntry{
×
137
                Timestamp:  time.Now(),
×
138
                EventType:  "step_complete",
×
139
                InstanceID: step.InstanceID,
×
NEW
140
                WorkflowID: instance.WorkflowID,
×
141
                StepID:     &step.ID,
×
142
                StepName:   step.StepName,
×
143
                Status:     string(step.Status),
×
144
                Metadata:   step.Output,
×
145
        }
×
146

×
147
        return p.logEvent(ctx, &entry)
×
148
}
×
149

150
func (p *AuditPlugin) logEvent(ctx context.Context, entry *AuditLogEntry) error {
×
151
        return p.writer.Write(ctx, entry)
×
152
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc