Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
anhhuu committed Dec 24, 2023
1 parent b3b291c commit 555a026
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Concurrent Executor for Asynchronous Task Execution
# conexec #

Package name: `anhhuu/conexec`
[![Build](https://github.com/anhhuu/conexec/workflows/build/badge.svg?branch=main)](https://github.com/anhhuu/conexec/actions)
[![Codecov](https://codecov.io/gh/anhhuu/conexec/branch/main/graph/badge.svg)](https://codecov.io/gh/anhhuu/conexec)
[![GoReportCard](https://goreportcard.com/badge/github.com/anhhuu/conexec)](https://goreportcard.com/report/github.com/anhhuu/conexec)
[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/anhhuu/conexec/blob/main/LICENSE)

## Overview
Package `anhhuu/conexec` (**Concurrent Executor for Asynchronous Task Execution**) provides a Concurrent Executor that facilitates the concurrent execution of multiple tasks, managing its own task queue. It is designed to handle asynchronous task execution with controlled concurrency and a task queue to ensure efficient resource utilization.

The `conexec` package provides a Concurrent Executor that facilitates the concurrent execution of multiple tasks, managing its own task queue. It is designed to handle asynchronous task execution with controlled concurrency and a task queue to ensure efficient resource utilization.
## Installation

## Features

- **Task Execution:** Execute tasks concurrently while respecting the specified maximum concurrent task limit.
- **Task Queue:** Manage a task queue to handle tasks that exceed the current concurrency limit.
- **Error Handling:** Capture and report errors during task execution.
- **Task Response:** Retrieve responses and errors for each completed task.
```bash
go get github.com/anhhuu/conexec
```

## Example

Expand Down Expand Up @@ -55,8 +55,21 @@ func main() {
}
```

## Features

- **Task Execution:** Execute tasks concurrently while respecting the specified maximum concurrent task limit.
- **Task Queue:** Manage a task queue to handle tasks that exceed the current concurrency limit.
- **Error Handling:** Capture and report errors/panics during task execution.
- **Task Response:** Retrieve responses and errors for each completed task.

## Usage

```go
import (
"github.com/anhhuu/conexec"
)
```

### Task Structure

```go
Expand All @@ -69,7 +82,7 @@ type Task struct {
type TaskExecutor func(ctx context.Context, args ...interface{}) (interface{}, error)
```

The `Task` struct represents a task with a unique identifier (`ID`), an executor function (`Executor`), and optional executor arguments (ExecutorArgs). The executor function takes a context and variable arguments and returns a value and an error.
The `Task` struct represents a task with a unique identifier (`ID`), an executor function (`Executor`), and optional executor arguments (`ExecutorArgs`). The executor function takes a context and variable arguments and returns a value and an error.

### Concurrent Executor Initialization

Expand All @@ -78,6 +91,14 @@ func NewConcurrentExecutor(maxConcurrentTasks, maxTaskQueueSize int) *Concurrent
```

Initialize a new Concurrent Executor with the specified maximum concurrent tasks and task queue size.
Or simple to use builder:

```go
concurrentExecutor := conexec.NewConcurrentExecutorBuilder().
WithMaxTaskQueueSize(defautMaxTaskQueueSize).
WithMaxConcurrentTasks(defaultMaxConcurrentTasks).
Build()
```

### Enqueue Task

Expand Down

0 comments on commit 555a026

Please sign in to comment.