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

Azure webpubsub service initial client library version #18199

Merged
merged 40 commits into from
Apr 26, 2021

Conversation

johanste
Copy link
Member

No description provided.

ClientType = TypeVar('ClientType', bound='WebPubSubServiceClient')


def build_authentication_token(endpoint, hub, key, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

We also need a from_connection_string version of this function.
Do you have any comments on this?

@johanste johanste requested a review from annatisch April 22, 2021 01:01
@johanste
Copy link
Member Author

/azp run prepare-pipelines

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

return self.__class__.ZERO


UTC = _UTC_TZ()
Copy link
Member

Choose a reason for hiding this comment

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

We should probably support the stdlib type where available:

try:
    from datetime import timezone
    UTC = timezone.utc
except ImportError:
    UTC = _UTC_TZ()


def _format_url(self, url):
# type: (str) -> str
assert self.endpoint[-1] != "/", "My endpoint should not have a trailing slash"
Copy link
Member

Choose a reason for hiding this comment

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

Would be kind of strange to encounter an AssertError when constructing the client?

Copy link
Member Author

Choose a reason for hiding this comment

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

In that scenario, this is truly an assert (we are stripping the trailing slash before calling the method). However, when looking at the code, the endpoint is a read/write attribute (which it probably shouldn't be) and the user could have set it to a value that does not conform to our assumptions. I may want to change self.endpoint to a read-only property...

if not self._internal_request.headers.get("Content-Length"):
try:
# set content length header if possible
self._internal_request.headers["Content-Length"] = str(len(self._internal_request.data)) # type: ignore
Copy link
Member

Choose a reason for hiding this comment

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

Is this going to be reliable?

class AsyncHttpResponse(_HttpResponseBase):

@property
def content(self) -> bytes:
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this property could live on _HttpResponseBase?

Copy link
Contributor

Choose a reason for hiding this comment

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

yep good point. it used to be different across sync and async, but no longer needed. Not going to update here though (it's fine to keep it like this), but will update in my core pr. thanks @annatisch !

await asyncio.sleep(0)

async def __aexit__(self, *args) -> None:
await self._internal_response.internal_response.__aexit__(*args)
Copy link
Member

Choose a reason for hiding this comment

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

Should we also be calling self.close() here?

Copy link
Contributor

Choose a reason for hiding this comment

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

that's a good point, let me call close instead to handle stream closing. Not sure if we want to update this in this pr @johanste , but will udpate in my core pr


- Python 2.7, or 3.6 or later is required to use this package.
- You need an [Azure subscription][azure_sub], and a [Azure WebPubSub service instance][webpubsubservice_docs] to use this package.
- An existing Azure Web PubSub service instance.
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a duplicate of the line above.

[webpubsubservice_docs]: https://aka.ms/awps/doc
[azure_cli]: https://docs.microsoft.com/cli/azure
[azure_sub]: https://azure.microsoft.com/free/
[webpubsubservice_client_class]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/signalr/azure-messaging-webpubsubservice/azure/messaging/webpubsubservice/__init__.py
Copy link
Member

Choose a reason for hiding this comment

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

move the azure-messaging-webpubsubservice into a new webpubsub folder instead of using signalr?

@check-enforcer
Copy link

This pull request is protected by Check Enforcer.

What is Check Enforcer?

Check Enforcer helps ensure all pull requests are covered by at least one check-run (typically an Azure Pipeline). When all check-runs associated with this pull request pass then Check Enforcer itself will pass.

Why am I getting this message?

You are getting this message because Check Enforcer did not detect any check-runs being associated with this pull request within five minutes. This may indicate that your pull request is not covered by any pipelines and so Check Enforcer is correctly blocking the pull request being merged.

What should I do now?

If the check-enforcer check-run is not passing and all other check-runs associated with this PR are passing (excluding license-cla) then you could try telling Check Enforcer to evaluate your pull request again. You can do this by adding a comment to this pull request as follows:
/check-enforcer evaluate
Typically evaulation only takes a few seconds. If you know that your pull request is not covered by a pipeline and this is expected you can override Check Enforcer using the following command:
/check-enforcer override
Note that using the override command triggers alerts so that follow-up investigations can occur (PRs still need to be approved as normal).

What if I am onboarding a new service?

Often, new services do not have validation pipelines associated with them, in order to bootstrap pipelines for a new service, you can issue the following command as a pull request comment:
/azp run prepare-pipelines
This will run a pipeline that analyzes the source tree and creates the pipelines necessary to build and validate your pull request. Once the pipeline has been created you can trigger the pipeline using the following comment:
/azp run python - [service] - ci

include azure/messaging/__init__.py
include LICENSE.txt
recursive-include tests *.py
recursive-include examples *.py *.md
Copy link
Member

Choose a reason for hiding this comment

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

We usually use folder name samples


token = six.ensure_str(jwt.encode(payload, key, algorithm="HS256"))
return {
"baseUrl": client_url,
Copy link
Member

Choose a reason for hiding this comment

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

Is the casing here a particular convention for this value?

'build_send_to_all_request',
'build_send_to_connection_request',
'build_send_to_group_request',
'build_send_to_user_request'
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing there are no operations groups for this API?
I saw there's been a shift to include operation groups in the namespace rather than the function name - but it seems that change has no impact on this SDK?

Copy link
Contributor

Choose a reason for hiding this comment

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

@annatisch @johanste has already done some manual-manipulation of the code, we completely got rid of the operation groups

@johanste johanste merged commit 4b456a8 into Azure:master Apr 26, 2021
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.

8 participants