Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: split parallel into analyzer_parallelism & emitter_parallelism #1068

Merged
merged 1 commit into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/analyzers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ queries:

### Parallel

`parallel` (`bool`) controls whether to allow parallel execution or not. Optional. Defaults to `false`. Configurable via `PARALLEL` environment variable.
`parallel` (`bool`) controls whether to allow parallel execution or not. Optional. Defaults to `false`. Configurable via `ANALYZER_PARALLELISM` environment variable.

### Pagination Interval

Expand Down
3 changes: 2 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ Alternatively you can set values through `.env` file. Values in `.env` file will

| Environment Variable | Type | Description | Default |
| ------------------------- | ------- | ----------------------------------------- | ------- |
| ANALYZER_PARALLELISM | Boolean | Whether to run analyzers in parallel | `false` |
| EMITTER_PARALLELISM | Boolean | Whether to run emitters in parallel | `true` |
| IGNORE_ERROR | Boolean | Whether to ignore error while querying | `false` |
| PAGINATION_INTERVAL | Integer | Pagination interval | `0` |
| PAGINATION_LIMIT | Integer | Pagination limit | `100` |
| PARALLEL | Boolean | Whether to run queries in parallel | `false` |
| RETRY_EXPONENTIAL_BACKOFF | Boolean | Whether to use retry exponential back off | `true` |
| RETRY_INTERVAL | Integer | Retry interval | `5` |
| RETRY_TIMES | Integer | Retry times | `3` |
Expand Down
2 changes: 1 addition & 1 deletion docs/emitters/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ options:

### Parallel

`parallel` (`bool`) controls whether to allow parallel execution or not. Optional. Defaults to `false`. Configurable via `PARALLEL` environment variable.
`parallel` (`bool`) controls whether to allow parallel execution or not. Optional. Defaults to `true`. Configurable via `EMITTER_PARALLELISM` environment variable.
2 changes: 1 addition & 1 deletion lib/mihari/analyzers/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def ignore_error?
# @return [Boolean]
#
def parallel?
options[:parallel] || Mihari.config.parallel
options[:parallel] || Mihari.config.analyzer_parallelism
end

# @return [Array<String>, Array<Mihari::Models::Artifact>]
Expand Down
8 changes: 6 additions & 2 deletions lib/mihari/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ class Config < Anyway::Config
ignore_error: false,
pagination_interval: 0,
pagination_limit: 100,
parallel: false,
analyzer_parallelism: false,
emitter_parallelism: true,
retry_exponential_backoff: true,
retry_interval: 5,
retry_times: 3,
Expand Down Expand Up @@ -146,7 +147,10 @@ class Config < Anyway::Config
# @!attribute [r] pagination_limit
# @return [Integer]

# @!attribute [r] parallel
# @!attribute [r] analyzer_parallelism
# @return [Boolean]

# @!attribute [r] emitter_parallelism
# @return [Boolean]

# @!attribute [r] ignore_error
Expand Down
2 changes: 1 addition & 1 deletion lib/mihari/emitters/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def initialize(rule:, options: nil)
# @return [Boolean]
#
def parallel?
options[:parallel] || Mihari.config.parallel
options[:parallel] || Mihari.config.emitter_parallelism
end

# A target to emit the data
Expand Down