Skip to content

Commit

Permalink
wip(runtime): fixing example with adder
Browse files Browse the repository at this point in the history
  • Loading branch information
emil14 committed Oct 10, 2023
1 parent 3e94b85 commit 7857c7e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions internal/runtime/func_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

var (
ErrFuncNotFound = errors.New("func not found")
ErrFunc = errors.New("func")
ErrFuncNotFound = errors.New("func not found")
ErrFuncConstructor = errors.New("func constructor")
)

const CtxMsgKey = "msg"
Expand Down Expand Up @@ -50,7 +50,7 @@ func (d DefaultFuncRunner) Run(ctx context.Context, funcRoutines []FuncCall) (er

fun, err := constructor(ctx, routine.IO)
if err != nil {
return fmt.Errorf("%w: %v", errors.Join(ErrFunc, err), routine.Ref)
return fmt.Errorf("%w: %v: ref %v", ErrFuncConstructor, err, routine.Ref)
}

go func() {
Expand Down
4 changes: 2 additions & 2 deletions internal/runtime/funcs/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func ParseInt(ctx context.Context, io runtime.FuncIO) (func(), error) {
return nil, err
}

errout, err := io.Out.Port("err")
errout, err := io.Out.Port("err") // FIXME no err port here!
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -258,6 +258,6 @@ func Repo() map[string]runtime.Func {
"Lock": Lock,
"Const": Const,
"Add": Add,
"ParseNum": ParseInt,
"ParseInt": ParseInt,
}
}
2 changes: 1 addition & 1 deletion internal/runtime/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var ErrSinglePortCount = errors.New("number of ports found by name not equals to
func (f FuncPorts) Port(name string) (chan Msg, error) {
slots, ok := f[name]
if !ok {
return nil, fmt.Errorf("")
return nil, fmt.Errorf("port not found by name: %v", name)
}

if len(slots) != 1 {
Expand Down
4 changes: 2 additions & 2 deletions internal/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
ErrStartPortNotFound = errors.New("enter port not found")
ErrExitPortNotFound = errors.New("exit port not found")
ErrConnector = errors.New("connector")
ErrRoutineRunner = errors.New("routine runner")
ErrFuncRunner = errors.New("func runner")
)

func (r Runtime) Run(ctx context.Context, prog Program) (code int, err error) {
Expand All @@ -66,7 +66,7 @@ func (r Runtime) Run(ctx context.Context, prog Program) (code int, err error) {

g.Go(func() error {
if err := r.funcRunner.Run(gctx, prog.Funcs); err != nil {
return fmt.Errorf("%w: %v", ErrRoutineRunner, err)
return fmt.Errorf("%w: %v", ErrFuncRunner, err)
}
return nil
})
Expand Down

0 comments on commit 7857c7e

Please sign in to comment.