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

[Tracking Issue] Convert Cosmos to Pipeline Architecture #290

Closed
17 of 55 tasks
rylev opened this issue Jun 11, 2021 · 8 comments
Closed
17 of 55 tasks

[Tracking Issue] Convert Cosmos to Pipeline Architecture #290

rylev opened this issue Jun 11, 2021 · 8 comments
Labels
Azure.Core The azure_core crate Cosmos The azure_cosmos crate design-discussion An area of design currently under discussion and open to team and community feedback. good first issue This issue tracks work that may be a good starting point for a first-time contributor help wanted This issue is tracking work for which community contributions would be welcomed and appreciated

Comments

@rylev
Copy link
Contributor

rylev commented Jun 11, 2021

This is a tracking issue for converting operations over to the pipeline architecture. There are some sub issues for converting individual SDK crates over, but this issue acts as a guide for how to switch to the new architecture.

Overview

Previous to the pipeline architecture, each operation was independently controlled meaning there was no central way to control the way operations were performed.

The pipeline architecture on the other hand allows users of the SDK to create pipelines through which outgoing requests and incoming responses are processed. The pipeline are composed of "policies" which can both change the outgoing request and the incoming response. Policies are usually either on a "per-request" basis (meaning they are called only once per operation) or "per-retry" (meaning they are applied every time an operation is attempted).

Examples of policies are the TelemetryPolicy which adds various telemetry headers to the request and the retry policy which checks whether an incoming response was successful and if it detects a transient failure, retries the request.

Converting to the Architecture

For an example of converting one operation (Cosmos's get_database operation) over to the pipeline architecture, take a look at #286.

The basic steps are:

  • Create a new submodule of the operations module where the operation will live. This submodule should be named after the operation (e.g., for get_database it's called get_database).
  • Move the "request builder" (e.g., for get_database the GetDatabaseBuilder) to new operation submodule and rename it from Builder to Options (e.g., GetDatabaseBuilder => GetDatabaseOptions`). This now represents the options that can be supplied when performing the operation. Note that many options that were part of the builder are no longer valid options because there will be individual policies that take their place. For instance, previously many operations took an option to set the user agent. This is now done by a policy.
  • Change the execute method to a decorate_request method that instead of performing the request, simply mutates a request parameter with any of the options supplied.
  • Move the associated response type (e.g., for get_database the GetDatabaseResponse type from the responses submodule to the operation submodule. Previously a std::convert::TryFrom implementation was used to convert from an http::Response<Bytes> object. This should now be a plain associated async function called try_from that converts from the new Response type. See the example for how this should be done.
  • Finally, convert the appropriate method on the appropriate client (e.g., for get_database this was the DatabaseClient::get_database) to use the new options and response types with the pipeline. Again, see the example for how this should be done.

Todos

  • Attachments
    • delete_attachment
    • get_attachment
    • list_attachments
  • Collections
    • create_collection
    • delete_collection
    • get_collection
    • list_collections
    • replace_collection
  • Databases
    • create_database
    • delete_database
    • list_databases
    • get_database
  • Documents
    • create_document
    • delete_document
    • get_document
    • replace_document
    • list_documents
    • query_documents
  • Partition Key Ranges
    • get_partition_key_ranges
  • Permissions
    • create_permission
    • delete_permission
    • get_permission
    • replace_permission
    • list_permissions
  • Reference Attachments
    • create_reference_attachment
    • replace_reference_attachment
  • Slug Attachments
    • create_slug_attachment
    • create_stored_procedure
    • delete_stored_procedure
    • execute_stored_procedure
    • replace_stored_procedure
  • Stored Prodedures
    • list_stored_procedures
  • Triggers
    • create_trigger
    • delete_trigger
    • list_triggers
  • Users
    • create_user
    • delete_user
    • get_user
    • replace_user
  • User Defined Functions
    • create_user_defined_function
    • delete_user_defined_function
    • list_user_defined_functions
    • list_users
@rylev rylev added good first issue This issue tracks work that may be a good starting point for a first-time contributor help wanted This issue is tracking work for which community contributions would be welcomed and appreciated pipeline labels Jun 11, 2021
yoshuawuyts added a commit to yoshuawuyts/azure-sdk-for-rust that referenced this issue Aug 3, 2021
This converts from the older req/res-style API into the newer pipeline-based API (ref: Azure#290).
yoshuawuyts added a commit to yoshuawuyts/azure-sdk-for-rust that referenced this issue Aug 3, 2021
This converts from the older req/res-style API into the newer pipeline-based API (ref: Azure#290).
rylev pushed a commit that referenced this issue Aug 3, 2021
This converts from the older req/res-style API into the newer pipeline-based API (ref: #290).
@yoshuawuyts
Copy link
Contributor

@JoshGendein
Copy link
Member

I'll pick up create_permission, get_permission, replace_permission, and delete_permission

eholk added a commit to eholk/azure-sdk-for-rust that referenced this issue Sep 1, 2021
This change begins the migration process for moving get_document to the
new pipelines architecture. Most of the code is moved over now, but the
example programs still need updated.

Issue Azure#290
@eholk
Copy link
Contributor

eholk commented Sep 1, 2021

I've started working on get_document at https://github.com/eholk/azure-sdk-for-rust/tree/cosmos-get-document.

@yoshuawuyts yoshuawuyts pinned this issue Sep 6, 2021
rylev pushed a commit that referenced this issue Sep 7, 2021
* [Cosmos] Start migrating get_document to pipelines

This change begins the migration process for moving get_document to the
new pipelines architecture. Most of the code is moved over now, but the
example programs still need updated.

Issue #290

* Make examples compile with get_document pipelines version

* Remove dead code

* Fix e2e test compilation errors
@nalshihabi
Copy link

I have started working on create_stored_procedure delete_stored_procedure execute_stored_procedure. Also, I think some of these stored procedures related methods are incorrectly listed under Slug Attachments.

@JoshGendein
Copy link
Member

JoshGendein commented Sep 22, 2021

I'll start on get_collection and delete_collection.

EDIT: Also replace_collection which it looks like isn't in the list above.

@jddarby
Copy link
Contributor

jddarby commented Oct 5, 2021

I have started get_attachment in #375. First time contributing so let me know if I've missed anything.

@thovoll
Copy link
Contributor

thovoll commented Oct 20, 2021

@rylev is this issue meant for CosmosDB only?

@cataggar cataggar added this to the azure_cosmos 0.1.0 milestone Oct 22, 2021
@cataggar cataggar added the Cosmos The azure_cosmos crate label Oct 25, 2021
@cataggar cataggar changed the title [Tracking Issue] Converting to Pipeline Architecture [Tracking Issue] Convert Cosmos to Pipeline Architecture Oct 25, 2021
@cataggar cataggar unpinned this issue Nov 2, 2021
@cataggar
Copy link
Member

#677 claimed to complete this 🥳

@cataggar cataggar unpinned this issue Mar 24, 2022
@heaths heaths added Azure.Core The azure_core crate design-discussion An area of design currently under discussion and open to team and community feedback. labels Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Core The azure_core crate Cosmos The azure_cosmos crate design-discussion An area of design currently under discussion and open to team and community feedback. good first issue This issue tracks work that may be a good starting point for a first-time contributor help wanted This issue is tracking work for which community contributions would be welcomed and appreciated
Projects
None yet
Development

No branches or pull requests

9 participants