Giter Club home page Giter Club logo

msacore / pipe Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 68 KB

๐Ÿ— [WIP!]: Use the full power of Go channels with the pipeline pattern. This module will help you to organize the most productive solution by supplying a set of ready-made conveyor elements like Split, Route, Spread, Join, Filter, Map and so on. It's as simple as playing a game like Factorio, Mindustry or Satisfactory!

Home Page: https://pkg.go.dev/github.com/msacore/pipe

License: MIT License

Go 98.61% Makefile 1.39%
conveyor framework gamification goroutines microservices parallel pipeline

pipe's People

Contributors

jkulvich avatar

Watchers

 avatar

pipe's Issues

Functions builder

I would like to see some generic functions to construct my own pipeline functions. In concept, it might look like:

import "github.com/msacore/pipe/builder"

...

fn := builder.
  WithInputs(in1, in2).
  WithOutputs(out1, out2).
  WithCloser(closer.Some). // const
  WithCapacity(capacity.Same). // const
  WithStrategy(strategy.Parallel). // func
  WithHandler(???).
  Build(ctx)

...

func Split(...) {
  return fn(...)
}

Of course, we need some more research about how to implement and use different atomic strategies with atomic handlers. I mean, how the handler should work and the Builder should understand for different functions like Split and Merge for example.

These functions have conceptually different algorithms where Split just waits for a single input, and Merge waits for all inputs.

I guess, this problem can be solved with different handler functions builder, like WithHandlerAll and WithHandlerSome and WithHandlerSingle (specific case of WithHandlerAll)

โญ๏ธ [FEATURE]: Add tuple generic types

Is your feature request related to a problem? Please describe.
It can be tedious to declare a new structure every time we need to transfer various related data between the conveyor elements.

Describe the solution you'd like
Now we need to declare a new structure to communicate between pipes, I suggest next:

type msgOneToTwo = pipe.Tuple2[string, int]
type msgTwoToThree = pipe.Tuple2[int, string]

msg1 := make(chan msgOneToTwo, 2>>8)

msg2 := pipe.Map(..., func(msg msgOneToTwo) msgTwoToThree {
  return pipe.T2(msg.B, msg.A)
}, msg1)

... := pipe.Map(..., msg2)

Describe alternatives you've considered
I found a convenient solution to this problem using the samber/lo. It would be good to introduce tuples into the current module.

Additional context
none

โญ๏ธ [FEATURE]: Aborting pipe functions

Is your feature request related to a problem? Please describe.
Pipe aborting requires a bit of configuration, but we can reduce it.

Describe the solution you'd like
Now, we can abort operation with context, but we need to implement our own mechanism of aborting.
I suggest implement this feature as core feature for all pipe functions. I mean, we can stop calling of pipe function handlers in case of ctx.Done, and all rest and unread data for input channels must be read in the background.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
none

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.