PHOS
You Can (Not) Redo
PHOS is a channel with internal handlers and diversified options.
Install
go get github.com/B1NARY-GR0UP/phos
Quick Start
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
}
Configuration
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 |
Blogs
License
PHOS is distributed under the Apache License 2.0. The licenses of third party dependencies of PHOS are explained here.
ECOLOGY
PHOS is a Subproject of the Basic Middleware Service