Skip to content

Commit 6ce92dd

Browse files
committed
Fix linting issues
1 parent 6ea5b87 commit 6ce92dd

File tree

19 files changed

+42
-50
lines changed

19 files changed

+42
-50
lines changed

Taskfile.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ tasks:
4141
cmds:
4242
- golangci-lint run ./...
4343

44+
lint-fix:
45+
desc: Run linter
46+
cmds:
47+
- golangci-lint run ./... --fix
48+
4449
fmt:
4550
desc: Format code
4651
cmds:

cmd/smallflow/main.go

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package main
33
import (
44
"context"
55
"fmt"
6+
"time"
7+
68
"github.com/morebec/go-misas/misas"
79
"github.com/morebec/go-misas/mpostgres"
810
"github.com/morebec/go-misas/muuid"
@@ -11,7 +13,6 @@ import (
1113
adapters2 "github.com/morebec/smallflow/internal/orchestrator/adapters"
1214
"github.com/morebec/smallflow/internal/workflowmgmt"
1315
"github.com/morebec/smallflow/internal/workflowmgmt/adapters"
14-
"time"
1516
)
1617

1718
func main() {
@@ -30,26 +31,22 @@ func main() {
3031
panic(err)
3132
}
3233

33-
eventRegistry := mx.NewMessageRegistry[misas.EventTypeName, misas.Event]()
34+
mx.EventRegistry.Register(workflowmgmt.WorkflowEnabledEventTypeName, workflowmgmt.WorkflowEnabledEvent{})
35+
mx.EventRegistry.Register(workflowmgmt.WorkflowDisabledEventTypeName, workflowmgmt.WorkflowDisabledEvent{})
36+
mx.EventRegistry.Register(workflowmgmt.WorkflowTriggeredEventTypeName, workflowmgmt.WorkflowTriggeredEvent{})
37+
mx.EventRegistry.Register(workflowmgmt.WorkflowStartedEventTypeName, workflowmgmt.WorkflowStartedEvent{})
38+
mx.EventRegistry.Register(workflowmgmt.WorkflowEndedEventTypeName, workflowmgmt.WorkflowEndedEvent{})
39+
mx.EventRegistry.Register(workflowmgmt.StepStartedEventTypeName, workflowmgmt.StepStartedEvent{})
40+
mx.EventRegistry.Register(workflowmgmt.StepEndedEventTypeName, workflowmgmt.StepEndedEvent{})
3441

35-
eventRegistry.Register(workflowmgmt.WorkflowEnabledEventTypeName, workflowmgmt.WorkflowEnabledEvent{})
36-
eventRegistry.Register(workflowmgmt.WorkflowDisabledEventTypeName, workflowmgmt.WorkflowDisabledEvent{})
37-
eventRegistry.Register(workflowmgmt.WorkflowTriggeredEventTypeName, workflowmgmt.WorkflowTriggeredEvent{})
38-
eventRegistry.Register(workflowmgmt.WorkflowStartedEventTypeName, workflowmgmt.WorkflowStartedEvent{})
39-
eventRegistry.Register(workflowmgmt.WorkflowEndedEventTypeName, workflowmgmt.WorkflowEndedEvent{})
40-
eventRegistry.Register(workflowmgmt.StepStartedEventTypeName, workflowmgmt.StepStartedEvent{})
41-
eventRegistry.Register(workflowmgmt.StepEndedEventTypeName, workflowmgmt.StepEndedEvent{})
42-
43-
eventStore = mx.NewEventStoreDeserializerDecorator(eventStore, eventRegistry)
42+
eventStore = mx.NewEventStoreDeserializerDecorator(eventStore)
4443

4544
workflowRepo := &adapters.EventStoreWorkflowRepository{
4645
EventStore: eventStore,
47-
EventRegistry: eventRegistry,
4846
UUIDGenerator: muuid.NewRandomUUIDGenerator(),
4947
}
5048
runRepo := &adapters.EventStoreRunRepository{
5149
EventStore: eventStore,
52-
EventRegistry: eventRegistry,
5350
UUIDGenerator: muuid.NewRandomUUIDGenerator(),
5451
}
5552

@@ -109,11 +106,3 @@ func main() {
109106
fmt.Printf("Event %d: %T → %+v\n", i, event, event)
110107
}
111108
}
112-
113-
func registerActions() {
114-
//actionRegistry := definition.ActionRegistry{}
115-
//actionRegistry.Register(definition.NewActionFunc("my_action", func(ctx definition.Action) *definition.ActionError {
116-
// fmt.Println("Hello, World!")
117-
// return nil
118-
//}))
119-
}

internal/orchestrator/adapters/lease_inmemory.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package adapters
22

33
import (
44
"context"
5-
"github.com/morebec/smallflow/internal/orchestrator"
65
"sync"
6+
7+
"github.com/morebec/smallflow/internal/orchestrator"
78
)
89

910
type InMemoryWorkflowLeaseRepository struct {

internal/orchestrator/adapters/lease_postgres.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package adapters
22

33
import (
44
"context"
5+
56
"github.com/morebec/go-misas/mpostgres"
67
"github.com/morebec/smallflow/internal/orchestrator"
78
)
@@ -57,7 +58,6 @@ func (r PostgresWorkflowLeaseRepository) Update(ctx context.Context, lease orche
5758
}
5859

5960
return nil
60-
6161
}
6262

6363
func (r PostgresWorkflowLeaseRepository) Remove(ctx context.Context, workflowID string, runID string) error {

internal/orchestrator/lease.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package orchestrator
22

33
import (
44
"context"
5-
"github.com/morebec/go-misas/misas"
65
"time"
6+
7+
"github.com/morebec/go-misas/misas"
78
)
89

910
const defaultLeaseDuration = 5 * time.Minute

internal/orchestrator/orchestrator.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package orchestrator
33
import (
44
"context"
55
"fmt"
6+
67
"github.com/alitto/pond/v2"
78
"github.com/morebec/go-misas/misas"
89
"github.com/morebec/go-misas/muuid"
@@ -68,18 +69,15 @@ func (m *WorkflowOrchestrator) IsRunning() bool {
6869
func (m *WorkflowOrchestrator) HandleEvent(ctx context.Context, event misas.Event) misas.Error {
6970
switch e := event.(type) {
7071
case workflowmgmt.WorkflowTriggeredEvent:
71-
err := m.runWorkflow(ctx, e)
72-
if err != nil {
73-
return mx.NewInternalErrorFrom(err)
74-
}
72+
m.runWorkflow(ctx, e)
7573
return nil
7674
}
7775

7876
return nil
7977
}
8078

81-
func (m *WorkflowOrchestrator) runWorkflow(_ context.Context, e workflowmgmt.WorkflowTriggeredEvent) error {
82-
pond.Submit(func() {
79+
func (m *WorkflowOrchestrator) runWorkflow(_ context.Context, e workflowmgmt.WorkflowTriggeredEvent) {
80+
m.Pool.Submit(func() {
8381
runner := Worker{
8482
Clock: m.Clock,
8583
API: m.API,
@@ -90,5 +88,4 @@ func (m *WorkflowOrchestrator) runWorkflow(_ context.Context, e workflowmgmt.Wor
9088
fmt.Println("workflow runner error:", err)
9189
}
9290
})
93-
return nil
9491
}

internal/orchestrator/worker.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package orchestrator
33
import (
44
"context"
55
"fmt"
6+
"time"
7+
68
"github.com/morebec/go-misas/misas"
79
"github.com/morebec/smallflow/internal/workflowmgmt"
8-
"time"
910
)
1011

1112
const defaultLeaseHeartbeatDuration = time.Second * 30

internal/workflowmgmt/adapters/run_repo.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package adapters
22

33
import (
44
"context"
5+
56
"github.com/morebec/go-misas/misas"
67
"github.com/morebec/go-misas/muuid"
78
"github.com/morebec/go-misas/mx"
@@ -12,7 +13,6 @@ import (
1213
type EventStoreRunRepository struct {
1314
UUIDGenerator muuid.UUIDGenerator
1415
EventStore misas.EventStore
15-
EventRegistry *mx.MessageRegistry[misas.EventTypeName, misas.Event]
1616
}
1717

1818
func (r EventStoreRunRepository) Add(ctx context.Context, run *workflowmgmt.Run) misas.Error {
@@ -38,7 +38,6 @@ func (r EventStoreRunRepository) Add(ctx context.Context, run *workflowmgmt.Run)
3838
run.Commit()
3939

4040
return nil
41-
4241
}
4342

4443
func (r EventStoreRunRepository) Save(ctx context.Context, run *workflowmgmt.Run) misas.Error {
@@ -96,5 +95,4 @@ func (r EventStoreRunRepository) FindByID(ctx context.Context, workflowID string
9695
run.Apply(events)
9796

9897
return run, nil
99-
10098
}

internal/workflowmgmt/adapters/workflow_repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package adapters
33
import (
44
"context"
55
"fmt"
6+
67
"github.com/morebec/go-misas/misas"
78
"github.com/morebec/go-misas/muuid"
89
"github.com/morebec/go-misas/mx"
@@ -12,7 +13,6 @@ import (
1213

1314
type EventStoreWorkflowRepository struct {
1415
EventStore misas.EventStore
15-
EventRegistry *mx.MessageRegistry[misas.EventTypeName, misas.Event]
1616
UUIDGenerator muuid.UUIDGenerator
1717
}
1818

internal/workflowmgmt/api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package workflowmgmt
22

33
import (
44
"fmt"
5+
"time"
6+
57
"github.com/morebec/go-misas/misas"
68
"github.com/morebec/go-misas/muuid"
79
"github.com/morebec/go-misas/mx"
8-
"time"
910
)
1011

1112
func NewSubsystem(

0 commit comments

Comments
 (0)