apache / apache/pulsar

[Enhancement] Support reading config options from file in Function Java Runner (JavaInstanceStarter)

Open
#18,532 1 comment 0 reactions 0 assignees View on GitHub
Stale
Dominant language
Java
Stars
15.3k
Forks
3.8k
Avg merge
1d 14h
Merged PRs (30d)
160

Description

### Search before asking

- [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.

### Motivation

Currently the `JavaInstanceStarter` uses `JCommander` to parse command line args. However in certain cases reading from command line is not very flexible (think we need to use a env var as an argument but the container has no shell access). Thus we need to support reading configs from a file.

This is necessary for :
- https://github.com/streamnative/function-mesh/issues/368
- https://github.com/streamnative/function-mesh/issues/448

BTW, we can provide a new issue for python as well.

### Solution

Solution:

- add a new command line flag "--config_file" and accepts a file URl
- read the file using `PulsarConfigurationLoader` and create a new class` JavaInstanceConfiguration extends PulsarConfiguration`.
- Config priority : command line > conf file.
- Create a new validation class the make sure required field are either provided in the file or via command line interface (this means we need to make all JCommander required field non-required)

We need to make sure this new feature would not break any existing code.

### Alternatives

_No response_

### Anything else?

_No response_

### Are you willing to submit a PR?

- [X] I'm willing to submit a PR!

Contributor guide

Open the contributing guide

Research direction

Start at JavaInstanceStarter and inspect its JCommander argument parsing, then read how PulsarConfigurationLoader can load configuration files. Implement the --config_file flow and JavaInstanceConfiguration, preserving command-line precedence and validating required fields from either source. Done means existing command-line behavior remains compatible.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.