PHOS is a channel with internal handlers and diversified options.
go get github.com/B1NARY-GR0UP/phos
package main
import (
"context"
"fmt"
"github.com/B1NARY-GR0UP/phos"
)
func hello(_ context.Context, data string) (string, error) {
return data + " by ", nil
}
func world(_ context.Context, data string) (string, error) {
return data + "BINARY", nil
}
func main() {
ph := phos.New[string]()
defer ph.Close()
ph.Append(hello, world)
ph.In <- "PHOS"
res := <-ph.Out
ph.Delete(ph.Len() - 2)
fmt.Println(res.Data) // PHOS by BINARY
}
Option | Default | Description | Example |
---|---|---|---|
WithContext |
context.Background() |
Set context for PHOS | example |
WithZero |
false |
Set zero value for return when error happened | example |
WithTimeout |
3 * time.Second |
Set timeout for handlers execution | example |
WithErrHandleFunc |
nil |
Set error handle function for PHOS which will be called when handle error happened | example |
WithErrTimeoutFunc |
nil |
Set error timeout function for PHOS which will be called when timeout error happened | example |
WithErrDoneFunc |
nil |
Set err done function for PHOS which will be called when context done happened | example |
PHOS is distributed under the Apache License 2.0. The licenses of third party dependencies of PHOS are explained here.
PHOS is a Subproject of the Basic Middleware Service