Skip to content

Commit

Permalink
feat: support begin and final hook
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Jan 10, 2025
1 parent e3a8bae commit e676ce2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 1 addition & 4 deletions examples/helloworld.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@
- kind: print
filename: /dev/stdout
ports:
init:
begin:
- name: hello_world
port: in
env:
PORT:
- data: '{{ .PORT }}'

- kind: step
name: good_bye
Expand Down
2 changes: 2 additions & 0 deletions pkg/node/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import (
// Commonly used port names.
const (
PortInit = "init"
PortBegin = "begin"
PortTerm = "term"
PortFinal = "final"
PortIO = "io"
PortIn = "in"
PortOut = "out"
Expand Down
2 changes: 1 addition & 1 deletion pkg/symbol/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package symbol
import (
"context"
"errors"
"github.com/iancoleman/strcase"
"reflect"

"github.com/iancoleman/strcase"
"github.com/siyul-park/uniflow/pkg/resource"
"github.com/siyul-park/uniflow/pkg/scheme"
"github.com/siyul-park/uniflow/pkg/spec"
Expand Down
8 changes: 7 additions & 1 deletion pkg/symbol/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,13 @@ func (t *Table) load(sb *Symbol) error {
linked := t.linked(sb)
for _, sb := range linked {
if t.active(sb) {
if err := t.call(sb, node.PortInit); err != nil {
return err
}
if err := t.loadHooks.Load(sb); err != nil {
return err
}
if err := t.call(sb, node.PortInit); err != nil {
if err := t.call(sb, node.PortBegin); err != nil {
return err
}
}
Expand All @@ -294,6 +297,9 @@ func (t *Table) unload(sb *Symbol) error {
if err := t.unloadHooks.Unload(sb); err != nil {
return err
}
if err := t.call(sb, node.PortFinal); err != nil {
return err
}
}
}
return nil
Expand Down

0 comments on commit e676ce2

Please sign in to comment.