# thinhdanggroup/executor architecture

> Architecture diagram of the GitHub repository thinhdanggroup/executor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thinhdanggroup/executor
- Repository: https://github.com/thinhdanggroup/executor

## Overview

##### Project Type Analysis
This is a specialized open-source utility library focused on concurrent job execution in Go. The project is relatively small but serves a specific purpose: managing concurrent task execution with features like rate limiting and dynamic handler support.

##### Main Components

a. Core Components:
- Executor Pool Manager
- Worker Goroutines
- Job Queue
- Rate Limiter
- Dynamic Handler (Reflection-based)

b. Flow Components:
- Job Input Channel
- Job Distribution System
- Worker Execution Flow
- Result Handling

##### Input/Output Flow
- Left side: Job submission interface
- Right side: Job execution results

##### Supporting Components
- Rate Limiter (Rectangle with throttle symbol)
- Job Queue (Queue symbol or rectangle with stacked lines)

**[Client Code] → [Job Submission Interface] → [Executor Pool Manager] → [Workers] → [Results]**
- ↑
- [Rate Limiter]
- [Dynamic Handler]

##### Implementation Details to Highlight

- Job submission interface (Publish method)
- Worker pool initialization
- Rate limiting mechanism
- Dynamic function handling through reflection
- Resource cleanup (Close method)

##### Additional Notes

- The simplicity of the public API
- The complexity handled internally
- The concurrent execution model
- The dynamic nature of job handling

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Legend
        L1[Component]
        L2[(Queue)]
        L3([Rate Limited Component])
        L4{{Dynamic Component}}
        L5>Result]
    end

    subgraph Client
        CC[Client Code]:::client
        EX[Examples]:::client
        click EX "https://github.com/thinhdanggroup/executor/blob/master/examples/example.go"
    end

    subgraph "Executor System"
        EPM[Executor Pool Manager]:::manager
        click EPM "https://github.com/thinhdanggroup/executor/blob/master/executor.go"

        subgraph "Job Processing"
            JQ[(Job Queue)]:::queue
            click JQ "https://github.com/thinhdanggroup/executor/blob/master/executor.go"
            
            RL([Rate Limiter]):::ratelimit
            click RL "https://github.com/thinhdanggroup/executor/blob/master/executor.go"
            
            DH{{Dynamic Handler}}:::dynamic
            click DH "https://github.com/thinhdanggroup/executor/blob/master/executor.go"
        end

        subgraph "Worker Pool"
            W1[Worker 1]:::worker
            W2[Worker 2]:::worker
            W3[Worker 3]:::worker
            W4[...Worker N]:::worker
            click W1 "https://github.com/thinhdanggroup/executor/blob/master/executor.go"
            click W2 "https://github.com/thinhdanggroup/executor/blob/master/executor.go"
            click W3 "https://github.com/thinhdanggroup/executor/blob/master/executor.go"
            click W4 "https://github.com/thinhdanggroup/executor/blob/master/executor.go"
        end

        RH>Results Handler]:::results
    end

    %% Connections
    CC --> EX
    EX --> EPM
    EPM --> JQ
    JQ --> RL
    RL --> DH
    DH --> W1
    DH --> W2
    DH --> W3
    DH --> W4
    W1 --> RH
    W2 --> RH
    W3 --> RH
    W4 --> RH

    %% Styles
    classDef client fill:#e1f5fe,stroke:#01579b
    classDef manager fill:#4caf50,stroke:#1b5e20,color:#fff
    classDef queue fill:#fff59d,stroke:#f57f17
    classDef ratelimit fill:#ffccbc,stroke:#bf360c
    classDef dynamic fill:#e1bee7,stroke:#4a148c
    classDef worker fill:#90caf9,stroke:#0d47a1
    classDef results fill:#a5d6a7,stroke:#1b5e20
```
