Code Monkey home page Code Monkey logo

goio's People

Contributors

andzh1 avatar codacy-badger avatar primetalk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

deepch

goio's Issues

Add maps.Merge

It should combine two maps. In case when a key is present in both maps, it should combine values.

PairBoth -> p.Both

A method could be more convenient. The old variant should be kept for compatibility.

Add io.MapSlice

Maps a slice inside IO.

Something like monad transformer.

Add io.RunAlso

Runs a second IO[Unit] in parallel. Automatically performs conversion to Either and back to A.

Add pair.Both

Golang allows to return two values simultaneously. We should leverage that in pairs.

Add sets.Contains

This should be a curried function convenient to use with Filter.

func Contains[A comparable](as map[A]struct{}) func(a A) bool

Add fiber.JoinWithTimeout

We should be able to specify a timeout when joining fiber. In this case it'll error out with timeout exception.

Add set.MapKeys

This should create another map with transformed keys.
It should allow aggregation of values if the key happened to be the same.

Add stream.Wrapf

Each IO element of the stream should be wrapped. So that if any of them fail, stream will produce a wrapped error.

Add stream.Last

Maintain the current value in state. On finish it should return the last preserved value.

Add ThroughExecutionContextUnordered

Currently we have ThroughExecutionContext which preserves the order of tasks. If one of the tasks takes much longer, it'll delay other tasks.
We might want to support unordered execution to achieve maximum throughput.

Add Cancellable

go-lang context.Context might be used for compatibility purposes.

Add benchmark

Hey nice library!

Would be good to understand the perks and what not of using this against an imperative approach.
Can you add benchmarks reports in the README file pls?

Docs divergence

In readme it says:

io.MapPure[A, B](ioa IO[A], f func(A)B) IO[B]
io.Map[A, B](ioa IO[A], f func(A)(B, error)) IO[B]

but the real signature is

func Map[A any, B any](ioA IO[A], f func(a A) B) IO[B]

Support transaction-like resources

Some resources require different action in case of failure. In particular, DB transactions and S3 multipart uploads.

t := transaction.New[T](acquire IO[T], rollback, commit func(T) IO) transaction.TransactionalResource[T]
transaction.Within[T, A](t, func (t) IO[A]) IO[A]

Get rid of deep call stacks

github.com/primetalk/goio/io.Eval[...].func1
	github.com/primetalk/[email protected]/io/io.go:50
github.com/primetalk/goio/io.FlatMap[...].func1
	github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.Fold[...].func1
	github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.MapErr[...].func1
	github.com/primetalk/[email protected]/io/io.go:91
github.com/primetalk/goio/io.FlatMap[...].func1.1
	github.com/primetalk/[email protected]/io/io.go:129
github.com/primetalk/goio/io.MapErr[...].func1
	github.com/primetalk/[email protected]/io/io.go:91
github.com/primetalk/goio/io.MapErr[...].func1
	github.com/primetalk/[email protected]/io/io.go:110
github.com/primetalk/goio/io.FlatMap[...].func1
	github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.Fold[...].func1
	github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.MapErr[...].func1
	github.com/primetalk/[email protected]/io/io.go:91
github.com/primetalk/goio/io.FlatMap[...].func1.1
	github.com/primetalk/[email protected]/io/io.go:129
github.com/primetalk/goio/io.FlatMap[...].func1
	github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.FlatMap[...].func1
	github.com/primetalk/[email protected]/io/io.go:140
github.com/primetalk/goio/io.FlatMap[...].func1
	github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.FlatMap[...].func1
	github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.FlatMap[...].func1
	github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.FlatMap[...].func1
	github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.FlatMap[...].func1
	github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.Fold[...].func1
	github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.FlatMap[...].func1.1
	github.com/primetalk/[email protected]/io/io.go:129
github.com/primetalk/goio/io.Fold[...].func1
	github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.Fold[...].func1
	github.com/primetalk/[email protected]/io/io.go:186
github.com/primetalk/goio/io.FlatMap[...].func1.1
	github.com/primetalk/[email protected]/io/io.go:129
github.com/primetalk/goio/io.FlatMap[...].func1
	github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.FlatMap[...].func1
	github.com/primetalk/[email protected]/io/io.go:140
github.com/primetalk/goio/io.Fold[...].func1
	github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.FlatMap[...].func1
	github.com/primetalk/[email protected]/io/io.go:124
github.com/primetalk/goio/io.Fold[...].func1
	github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.FlatMap[...].func1.1
	github.com/primetalk/[email protected]/io/io.go:129
github.com/primetalk/goio/io.Fold[...].func1
	github.com/primetalk/[email protected]/io/io.go:172
github.com/primetalk/goio/io.Fold[...].func1
	github.com/primetalk/[email protected]/io/io.go:186

Add conditional retry

Signature might look like

func Retry[A any, S any](ioa IO[A], strategy func(s S, err error) option.Option[S], s S) IO[A]

s - state of the strategy. Strategy might use it to count the number of retries, or time between invocations. If strategy decides not to retry, it should return option.None.

Add stream.Partition

It might have the following signature:

func Partition[A any](
  predicate func(A)bool,
  trueHandler func(Stream[A]) io.IO[Unit],
  falseHandler func(Stream[A]) io.IO[Unit],
) io.IO[Unit]

Resource management in streams

Currently streams can only use resources provided at the top level via ordinary resource.Use.
Sometimes we need to pass streams around and we wish that resources are correctly released when stream is either finished or thrown away.

Add slice.BuildUniqueIndex

If there is a unique key for slice elements, that key could be used to build a fast index based on map.

func BuildUniqueIndex[A any, K comparable](as []A, func (A) K) (map[K]A, err)

It may fail if the key value is not really unique.

Correlate output error with the input in ExecutionContext

When we run a few calculations in an ExecutionContext, we may lose information about what request failed. So instead of a simple GoResult we should keep some information about the source object.
This could be tricky, as we send IOs.

Add stream.SideEval

If we want to run some evaluation on every element, but then proceed stream processing with the very same element. For instance, log some statistics.

Add io.OnError

This should perform some operation on the error and fail with the same error.

Add stream.Buffer with min and max part size

This transducer should buffer incoming data and produce chunks of sizes within provided range.
Only if there is not enough data, the single part could be smaller than the required min amount.

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.