Skip to content

Async processing #667

Discussion options

You must be logged in to vote

Here the code if you want to implement the command:

ch := make(chan []byte) 
defer close(ch)
comp := compiler.New()
comp.RegisterFunction("consume", func(ctx context.Context, args ...core.Value) (core.Value, error) {
    err := core.ValidateArgs(args, 1, 1)
    if err != nil {
        return values.None, nil
     }
     j, _ := values.ToArray(ctx, args[0]).MarshalJSON()
     ch <- j
     return values.None, nil
})

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ziflex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
type/question Further information is requested area/runtime Runtime issue
2 participants
Converted from issue

This discussion was converted from issue #313 on September 20, 2021 00:32.