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

[component/functions|component/go] Propagate user-config parameter into instances of Golang pulsar functions #8132

Conversation

vaihtovirta
Copy link
Contributor

@vaihtovirta vaihtovirta commented Sep 25, 2020

Motivation

Currently, pulsar functions written in Golang have no access to the content of the user-config parameter from admin CLI.
That's the simplest way to pass custom configuration into a go function right now because neither secretsMap nor Kubernetes runtime is available for Golang functions yet.

Note: For the secretsMap parameter, the same technique can be used, but this has to be addressed in a separate PR.

Modifications

  • Added String GoInstanceConfig#userConfig attribute
  • Propagated user-config parameter in RuntimeUtils.getGoInstanceCmd
  • Exposed userConfig in pulsar-function-go and made it available in the FunctionContext
  • Add unit tests for the affected code

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Added unit tests for RuntimeUtils.getGoInstanceCmd in pulsar-functions
  • Added unit tests for instanceConf and FunctionContext in pulsar-function-go

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (yes)
    • Run go mod tidy in pulsar-function-go.
  • The public API: (no)
  • The schema: (yes)
    • New attribute in GoInstanceConfig.java
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • Anything that affects deployment: (don't know)

Documentation

The respective documentation has to be updated: User Config#Go

Question: Does it have to be done in the scope of current PR?

@vaihtovirta vaihtovirta force-pushed the feat/pulsar-function-go/add-user-config-support branch from 354ed6a to 0b91888 Compare September 27, 2020 11:30
@@ -72,8 +73,8 @@ func newInstanceConf() *instanceConf {
SubscriptionType: pb.SubscriptionType(cfg.SubscriptionType),
InputSpecs: map[string]*pb.ConsumerSpec{
cfg.SourceSpecTopic: {
SchemaType: cfg.SourceSchemaType,
IsRegexPattern: cfg.IsRegexPatternSubscription,
SchemaType: "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you change the SchemaType to an empty string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I might've overlooked after some testing.
I'll revert that.

SchemaType: cfg.SourceSchemaType,
IsRegexPattern: cfg.IsRegexPatternSubscription,
SchemaType: "",
IsRegexPattern: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you change this to false?

@vaihtovirta
Copy link
Contributor Author

@sijie Addressed both comments.

@vaihtovirta vaihtovirta requested a review from sijie October 1, 2020 09:11
@sijie sijie added this to the 2.7.0 milestone Oct 2, 2020
@sijie sijie added area/function component/go type/feature The PR added a new feature or issue requested a new feature labels Oct 2, 2020
@sijie sijie merged commit d6f18ab into apache:master Oct 5, 2020
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Nov 13, 2020
…to instances of Golang pulsar functions (apache#8132)

### Motivation

Currently, pulsar functions written in Golang have no access to the content of the user-config parameter from admin CLI.
That's the simplest way to pass custom configuration into a go function right now because neither secretsMap nor Kubernetes runtime is available for Golang functions yet.

**Note**: For the `secretsMap` parameter, the same technique can be used, but this has to be addressed in a separate PR.

### Modifications

- Added `String GoInstanceConfig#userConfig` attribute
- Propagated user-config parameter in `RuntimeUtils.getGoInstanceCmd`
- Exposed userConfig in `pulsar-function-go` and made it available in the `FunctionContext`
- Add unit tests for the affected code
@codelipenghui
Copy link
Contributor

depends by #8268

codelipenghui pushed a commit that referenced this pull request Dec 7, 2020
…to instances of Golang pulsar functions (#8132)

### Motivation

Currently, pulsar functions written in Golang have no access to the content of the user-config parameter from admin CLI.
That's the simplest way to pass custom configuration into a go function right now because neither secretsMap nor Kubernetes runtime is available for Golang functions yet.

**Note**: For the `secretsMap` parameter, the same technique can be used, but this has to be addressed in a separate PR.

### Modifications

- Added `String GoInstanceConfig#userConfig` attribute
- Propagated user-config parameter in `RuntimeUtils.getGoInstanceCmd`
- Exposed userConfig in `pulsar-function-go` and made it available in the `FunctionContext`
- Add unit tests for the affected code 

(cherry picked from commit d6f18ab)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/function release/2.6.3 type/feature The PR added a new feature or issue requested a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants