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 keyFilePath, emulatorHost and projectId as configuration parameters #6

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ricktap
Copy link

@ricktap ricktap commented Sep 15, 2021

adds keyFilePath, emulatorHost and projectId as described in #5

  • describe the symfony 5.3 behaviour
  • document new configuration options
  • replace deprecated GCLOUD_PROJECT environment variable in documentation
  • resolve additional options as environment variables

* describe the symfony 5.3 behaviour
* document new configuration options
* replace deprecated GCLOUD_PROJECT environment variable in documentation
* resolve additional options as environment variables
Copy link
Member

@marforon marforon left a comment

Choose a reason for hiding this comment

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

Thank you @ricktap for your work! I have som proposes but generally I agree with your PR.


const GOOGLE_APPLICATION_CREDENTIALS = 'GOOGLE_APPLICATION_CREDENTIALS';
const GOOGLE_CLOUD_PROJECT = 'GOOGLE_CLOUD_PROJECT';
const PUBSUB_EMULATOR_HOST = 'PUBSUB_EMULATOR_HOST';
Copy link
Member

Choose a reason for hiding this comment

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

Could you please use explicit constant access visibility? I also propose to rename these contants as it's not obvious what they represent.

public const KEY_FILE_PATH_ENV_NAME = 'GOOGLE_APPLICATION_CREDENTIALS';
public const PROJECT_ID_ENV_NAME = 'GOOGLE_CLOUD_PROJECT';
public const EMULATOR_HOST_ENV_NAME = 'PUBSUB_EMULATOR_HOST';

'projectId' => self::GOOGLE_CLOUD_PROJECT,
'emulatorHost' => self::PUBSUB_EMULATOR_HOST,
'keyFilePath' => self::GOOGLE_APPLICATION_CREDENTIALS
];
Copy link
Member

Choose a reason for hiding this comment

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

I propose to put it into private constant as:

private const ENV_OPTIONS_MAP = [
    'projectId' => self::PROJECT_ID_ENV_NAME,
    'emulatorHost' => self::EMULATOR_HOST_ENV_NAME,
    'keyFilePath' => self::KEY_FILE_PATH_ENV_NAME,
];

```php
(new Dotenv())->usePutenv()->...
```
Copy link
Member

Choose a reason for hiding this comment

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

I think this whole part about using ->usePutenv can be deleted. By this PR we are going to force use of putenv by resolving gps transport options and it's ok, because Google library can only work with globaly accessible env vars.

Copy link

@chrishemmings chrishemmings Jan 5, 2022

Choose a reason for hiding this comment

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

You don't need to use env vars anymore. You can pass all these options in when you instantiate the PubSubClient.

https://googleapis.github.io/google-cloud-php/#/docs/google-cloud/v0.172.0/pubsub/pubsubclient?method=__construct

This is pretty much what I did when I forked this project over to https://github.com/chrishemmings/gps-messenger-bundle

@Bukashk0zzz
Copy link

Nice PR. @ricktap Any updates on it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants