Skip to content

Channel with internal handlers and diversified options.

License

Notifications You must be signed in to change notification settings

B1NARY-GR0UP/phos

Repository files navigation

PHOS

PHOS is a channel with internal handlers and diversified options.

Go Report Card

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

BMS

PHOS is a Subproject of the Basic Middleware Service