@@ -167,9 +167,10 @@ processNode := flyt.NewNode(
167167Actions are strings returned by a node's Post phase that determine what happens next:
168168
169169``` go
170- func (n *MyNode ) Post (ctx context .Context , shared *flyt .SharedStore , prepResult , execResult flyt .Result ) (flyt .Action , error ) {
171- // Type-safe access to result
172- if execResult.AsBoolOr (false ) {
170+ func (n *MyNode ) Post (ctx context .Context , shared *flyt .SharedStore , prepResult , execResult any ) (flyt .Action , error ) {
171+ // Convert to Result for type-safe access
172+ result := flyt.R (execResult)
173+ if result.AsBoolOr (false ) {
173174 return " success" , nil // Go to node connected with "success"
174175 }
175176 return " retry" , nil // Go to node connected with "retry"
@@ -245,16 +246,16 @@ user := User{
245246shared.Set (" user" , user)
246247
247248// Later, in a node's Prep function, bind it back to a struct
248- func (n *MyNode ) Prep (ctx context .Context , shared *flyt .SharedStore ) (flyt . Result , error ) {
249+ func (n *MyNode ) Prep (ctx context .Context , shared *flyt .SharedStore ) (any , error ) {
249250 var user User
250251 err := shared.Bind (" user" , &user) // Binds stored data to struct
251252 if err != nil {
252- return flyt. R ( nil ) , err
253+ return nil , err
253254 }
254255 // Or use MustBind (panics on failure - use for required data)
255256 // shared.MustBind("user", &user)
256257
257- return flyt. R ( user) , nil
258+ return user, nil
258259}
259260
260261// Utility methods
@@ -333,23 +334,25 @@ type CachedAPINode struct {
333334 cache map [string ]any
334335}
335336
336- func (n *CachedAPINode ) ExecFallback (prepResult flyt . Result , err error ) (flyt . Result , error ) {
337+ func (n *CachedAPINode ) ExecFallback (prepResult any , err error ) (any , error ) {
337338 // Return cached data when API fails
338- key := prepResult.MustString ()
339+ result := flyt.R (prepResult)
340+ key := result.MustString ()
339341 if cached , ok := n.cache [key]; ok {
340- return flyt. R ( cached) , nil
342+ return cached, nil
341343 }
342344 // Return default value if no cache
343- return flyt. R ( map [string ]any{" status" : " unavailable" }) , nil
345+ return map [string ]any{" status" : " unavailable" }, nil
344346}
345347
346- func (n *CachedAPINode ) Exec (ctx context .Context , prepResult flyt .Result ) (flyt .Result , error ) {
347- key := prepResult.MustString ()
348+ func (n *CachedAPINode ) Exec (ctx context .Context , prepResult any ) (any , error ) {
349+ result := flyt.R (prepResult)
350+ key := result.MustString ()
348351 data , err := callAPI (key)
349352 if err == nil {
350353 n.cache [key] = data // Update cache on success
351354 }
352- return flyt. R ( data) , err
355+ return data, err
353356}
354357```
355358
@@ -397,13 +400,13 @@ func NewRateLimitedNode(rps int) *RateLimitedNode {
397400 }
398401}
399402
400- func (n *RateLimitedNode ) Exec (ctx context .Context , prepResult flyt . Result ) (flyt . Result , error ) {
403+ func (n *RateLimitedNode ) Exec (ctx context .Context , prepResult any ) (any , error ) {
401404 if err := n.limiter .Wait (ctx); err != nil {
402- return flyt. R ( nil ) , err
405+ return nil , err
403406 }
404407 // Process with rate limiting
405- data , err := process (prepResult. Value () )
406- return flyt. R ( data) , err
408+ data , err := process (prepResult)
409+ return data, err
407410}
408411```
409412
@@ -430,10 +433,10 @@ func (n *CustomRetryNode) GetWait() time.Duration {
430433 return time.Duration (n.attempts ) * time.Second
431434}
432435
433- func (n *CustomRetryNode ) Exec (ctx context .Context , prepResult flyt . Result ) (flyt . Result , error ) {
436+ func (n *CustomRetryNode ) Exec (ctx context .Context , prepResult any ) (any , error ) {
434437 n.attempts ++
435- data , err := callAPI (prepResult. Value () )
436- return flyt. R ( data) , err
438+ data , err := callAPI (prepResult)
439+ return data, err
437440}
438441```
439442
@@ -443,9 +446,9 @@ Process multiple items concurrently:
443446
444447``` go
445448// Simple batch node for processing items
446- processFunc := func (ctx context.Context , item any) (flyt. Result , error ) {
449+ processFunc := func (ctx context.Context , item any) (any , error ) {
447450 // Process each item
448- return flyt. R ( fmt.Sprintf (" processed: %v " , item) ), nil
451+ return fmt.Sprintf (" processed: %v " , item), nil
449452}
450453
451454batchNode := flyt.NewBatchNode (processFunc, true ) // true for concurrent
@@ -465,9 +468,9 @@ config := &flyt.BatchConfig{
465468 CountKey : " total" , // Custom key for processed count
466469}
467470
468- processFunc := func (ctx context.Context , item any) (flyt. Result , error ) {
471+ processFunc := func (ctx context.Context , item any) (any , error ) {
469472 data , err := processItem (item)
470- return flyt. R ( data) , err
473+ return data, err
471474}
472475
473476batchNode := flyt.NewBatchNodeWithConfig (processFunc, true , config)
0 commit comments