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

Add GatewayPort configuration #67

Open
wants to merge 5 commits into
base: master
from

Conversation

@jonatasbaldin
Copy link

commented Sep 7, 2019

Description

Allows the User to configure a custom GatewayPort in nats-queue-worker. Fixes #59.

Motivation and Context

  • I have raised an issue to propose this change (required)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have signed-off my commits with git commit -s
  • I have added tests to cover my changes.
  • All new and existing tests passed.
Add faas_gateway_port env var and GatewayAddress config
Signed-off-by: Jonatas Baldin <jonatas.baldin@gmail.com>
Use GatewayAddress config when creating the gateway URL
Signed-off-by: Jonatas Baldin <jonatas.baldin@gmail.com>
Add faas_gateway_port in README
Signed-off-by: Jonatas Baldin <jonatas.baldin@gmail.com>

@derek derek bot added the new-contributor label Sep 7, 2019

@acornies
Copy link
Member

left a comment

This looks good to me.

@alexellis
Copy link
Member

left a comment

Sorry, just noticed these comments were pending and not sent yet.

@@ -114,6 +120,7 @@ func (ReadConfig) Read() QueueWorkerConfig {
type QueueWorkerConfig struct {
NatsAddress string
GatewayAddress string
GatewayPort string

This comment has been minimized.

Copy link
@alexellis

alexellis Sep 11, 2019

Member

Please read as an int

This comment has been minimized.

Copy link
@acornies

acornies Sep 11, 2019

Member

Good catch

This comment has been minimized.

Copy link
@jonatasbaldin
cfg.GatewayPort = val
} else {
cfg.GatewayPort = "8080"
}

This comment has been minimized.

Copy link
@alexellis

alexellis Sep 11, 2019

Member

We could probably concatenate the value once here instead of passing two arguments everywhere.

I think the new env var makes sense to prevent issues upgrading versions.

This comment has been minimized.

Copy link
@jonatasbaldin
main.go Outdated
pathVal,
qs)

if config.GatewayInvoke {
functionURL = fmt.Sprintf("http://%s:8080/function/%s%s%s",
functionURL = fmt.Sprintf("http://%s:%s/function/%s%s%s",

This comment has been minimized.

Copy link
@acornies

acornies Sep 11, 2019

Member

We should probably make the entire url configurable and do something like url.Parse(). Opens the door for https etc.

This comment has been minimized.

Copy link
@jonatasbaldin

jonatasbaldin Sep 11, 2019

Author

That's nice!

We could add yet a new variable called cfg.GatewayProtocol with http as the default value for backwards compatibility. What do you think?

Also, should we open a new issue/PR for that?

Change GatewayPort to int and concatenate it with GatewayAddress
Signed-off-by: Jonatas Baldin <jonatas.baldin@gmail.com>
Fix test_gatewayaddr test
Signed-off-by: Jonatas Baldin <jonatas.baldin@gmail.com>
@jonatasbaldin

This comment has been minimized.

Copy link
Author

commented Sep 11, 2019

I closed the PR by mistake 🤦‍♂ @alexellis, could you re run the build, please?

Also, you'll note that since I'm concatenating the cfg.GatewayAddress and cfg.GatewayPort I needed to change the test_gatewayaddr test to accommodate the port as well. It looks a bit odd, but it's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.