Run functions in parallel :comet:

Overview

Parallel fn

  • Run functions in parallel.
  • Limit the number of goroutines running at the same time.

Installation

go get -u github.com/rafaeljesus/parallel-fn

Usage

Run

package main

import (
  	"errors"

  	"github.com/rafaeljesus/parallel-fn"
)

func main() {
	timeout := time.After(2 * time.Second)
        fn1 := func() error { return nil }
        fn2 := func() error { return errors.New("BOOM!") }

	for {
		select {
		case err := <-Run(fn1, fn2):
                	// catch errors
		case <-timeout:
      			// handle timeout
		}
	}
}

RunLimit

package main

import (
  	"errors"

  	"github.com/rafaeljesus/parallel-fn"
)

func main() {
	timeout := time.After(2 * time.Second)
  	fn1 := func() error { return nil }
  	fn2 := func() error { return errors.New("BOOM!") }
  	fn3 := func() error { nil }
  	fn4 := func() error { nil }

	for {
		select {
		case err := <-RunLimit(2, fn1, fn2, fn3, fn4):
      			// catch errors
		case <-timeout:
      			// handle timeout
		}
	}
}

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

Badges

Build Status Go Report Card Go Doc


GitHub @rafaeljesus  ·  Medium @_jesus_rafael  ·  Twitter @_jesus_rafael

Owner
Rafael Jesus
fork() -> exec(...)
Rafael Jesus
Set up tasks to be executed in parallel.

A simple Go library to set up tasks to be executed in parallel. package main import ( "context" "log" "github.com/bep/workers" ) func main() {

Bjørn Erik Pedersen 9 Mar 6, 2022
Pengenalan Concurrency dan Parallel Programming

Golang Goroutine Sumber Tutorial: Udemy Slide Pengenalan Concurrency dan Parallel Programming Pengenalan Parallel Programming Saat ini kita hidup dima

Akbarputra 0 Nov 5, 2021
A safe way to execute functions asynchronously, recovering them in case of panic. It also provides an error stack aiming to facilitate fail causes discovery.

Async Provides a safe way to execute functions asynchronously, recovering them in case of panic. It also provides an error stack aiming to facilitate

Studio Sol Comunicação Digital Ltda 108 Jun 7, 2022
Hunch provides functions like: All, First, Retry, Waterfall etc., that makes asynchronous flow control more intuitive.

Hunch Hunch provides functions like: All, First, Retry, Waterfall etc., that makes asynchronous flow control more intuitive. About Hunch Go have sever

null 82 Jun 2, 2022
Limits the number of goroutines that are allowed to run concurrently

Golang Concurrency Manager Golang Concurrency Manager package limits the number of goroutines that are allowed to run concurrently. Installation Run t

Bui Thang 53 Jun 28, 2022
Run tasks concurrently with limits

Workerpool Package workerpool implements a concurrency limiting worker pool. Worker routines are spawned on demand as tasks are submitted. This packag

Cilium 18 Jun 8, 2022
Comet - Minimalist websocket framework for Go

Comet : fork Melody ?? Minimalist websocket framework for Go. Comet is websocket

tommy 1 Feb 8, 2022
parallel: a Go Parallel Processing Library

parallel: a Go Parallel Processing Library Concurrency is hard. This library doesn't aim to make it easy, but it will hopefully make it a little less

Ryan Skidmore 29 May 9, 2022
M3u8-parallel-downloader - M3u8 parallel downloader with golang

m3u8-parallel-downloader Usage ./m3u8-parallel-downloader -input http://example.

CzBiX 3 Feb 5, 2022
How we can run unit tests in parallel mode with failpoint injection taking effect and without injection race

This is a simple demo to show how we can run unit tests in parallel mode with failpoint injection taking effect and without injection race. The basic

amyangfei 1 Oct 31, 2021
A tool/library to run custom validations on Kubernetes resources in parallel

cluster-validator cluster-validator is a tool/library for performing resource validations in parallel on a Kubernetes cluster. For example, validating

Keiko Project 3 Mar 2, 2022
📊 parallel black box PostgreSQL unit tests run against a real database.

?? psql-docker-tests-example Parallel black box PostgreSQL unit tests run against a real database. Consider reading the Medium Story first. This packa

Adrian Brad 4 May 12, 2022
PHP functions implementation to Golang. This package is for the Go beginners who have developed PHP code before. You can use PHP like functions in your app, module etc. when you add this module to your project.

PHP Functions for Golang - phpfuncs PHP functions implementation to Golang. This package is for the Go beginners who have developed PHP code before. Y

Serkan Algur 48 Jun 4, 2022
YoMo 43 Jun 20, 2022
Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transforming and consuming them.

iter Package iter provides generic, lazy iterators, functions for producing them from primitive types, as well as functions and methods for transformi

Matthew Toohey 24 Jun 7, 2022
A wrapper for exposing a shared endpoint for Google Cloud Functions in go. API styled after Node.JS firebase-functions package.

firebase-fx A wrapper for Google Cloud Functions that simplifies the deployment of serverless applications. Meant to expose a similar API to the Fireb

Cleanflo Water Tech 5 May 18, 2022
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)

English / 日本語 ecsk ECS + Task = ecsk ?? ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run

null 101 Jun 20, 2022
A template project to demonstrate how to run WebAssembly functions as sidecar microservices in dapr

Live Demo 1. Introduction DAPR is a portable, event-driven runtime that makes it easy for any developer to build resilient, stateless and stateful app

Second State 121 Jun 21, 2022
Run multiple auth functions by relation

Relation Run multiple auth functions by relation. Signatures func New(relation string, conditions ...func(c *fiber.Ctx) bool) fiber.Handler Import imp

Eren BALCI 4 Oct 31, 2021
This Go package allows you to set handler functions that run when named events occur

This Go package allows you to set handler functions that run when named events occur

James 1 Feb 10, 2022
Authenticating using Workload Identity Federation to Cloud Run, Cloud Functions

Authenticating using Workload Identity Federation to Cloud Run, Cloud Functions This tutorial and code samples cover how customers that use Workload i

null 0 Feb 11, 2022
Count once - Just once? no, when appear many it run once, but it can run many times

countOnce just once? no, when appear many it run once, but it can run many times

null 1 Jan 29, 2022
Dependency-free replacement for GNU parallel, perfect fit for usage in an initramfs.

coshell v0.2.5 A no-frills dependency-free replacement for GNU parallel, perfect for initramfs usage. Licensed under GNU/GPL v2. How it works An sh -c

gdm85 41 May 11, 2022
A parallel downloader with resume capability

Grozilla The Grozilla is a simple implementation that allows downloading of video,audio,package or zip files parallely and efficiently using light wei

Prashant Agarwala 39 May 5, 2022
Next generation distributed, event-driven, parallel config management!

mgmt: next generation config management! About: Mgmt is a real-time automation tool. It is familiar to existing configuration management software, but

James 2.9k Jun 25, 2022
Go parallel gzip (de)compression

pgzip Go parallel gzip compression/decompression. This is a fully gzip compatible drop in replacement for "compress/gzip". This will split compression

Klaus Post 938 Jun 22, 2022
Parallel Digital Universe - A decentralized identity-based social network

Parallel Digital Universe Golang implementation of PDU. What is PDU? Usage Development Contributing PDU PDU is a decentralized identity-based social n

PDU.PUB 39 Jun 16, 2022
Parallel S3 and local filesystem execution tool.

s5cmd Overview s5cmd is a very fast S3 and local filesystem execution tool. It comes with support for a multitude of operations including tab completi

Peak 1.1k Jun 28, 2022
A library for parallel programming in Go

pargo A library for parallel programming in Go Package pargo provides functions and data structures for expressing parallel algorithms. While Go is pr

null 176 Jun 10, 2022