Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 28, 2025

Implementation of ReadMany API - refactored to separate file:

  • Rename ItemCoordinate to ItemIdentity with comprehensive doc comment
  • Change PartitionKey field from string to PartitionKey type
  • Add options to ReadManyOptions (SessionToken, ConsistencyLevel, DedicatedGatewayRequestOptions)
  • Handle 404 errors by skipping missing items instead of returning error
  • Update CHANGELOG.md with PR number 25516
  • Improve doc comment for ReadMany method to clarify optimization behavior
  • Update test to include item not requested (item4) and non-existent item in ReadMany call
  • Move ReadMany-related types and API to new cosmos_read_many.go file
  • Build and validate all changes
Original prompt

Add a new ReadMany API to the Cosmos DB SDK, in the ContainerClient type (in sdk/data/azcosmos/cosmos_container.go). The API should have the following signature:

type ItemCoordinate struct {
    ID string
    PartitionKey string
}

type ReadManyOptions struct {
    // ... to be filled in later, but DO generate this struct for future expansion later
}

type ReadManyResponse struct {
    // The items requested
    Items [][]byte
    // The total RU charge of the operation
    TotalRequestCharge float32
}

func (c *ContainerClient) ReadMany(itemCoordinates []ItemCoordinate, options *ReadManyOptions) (ReadManyResponse, error) {
    //...
}

Implement this by iterating through the list of "coordinates" and calling the existing Read API, collecting the total request charge as you go, to use it for the final TotalRequestCharge value. Perform no optimizations, just a sequential iteration. Include a test case in the emulator_cosmos_item_test.go file, but do not attempt to run it, as the CI can handle that.

Remember:

  • Write code comments ONLY when necessary to explain WHY certain code is used. DO NOT describe how code works, the code does that well enough.
  • Limit your implementation to what is asked for. Do not go above and beyond.
  • Do NOT include TODO or other comments describing future enhancements.
  • Include a CHANGELOG.md entry for this change. Include the PR link if you know it, otherwise just put "TBD" and we can fill it in later.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits October 28, 2025 17:07
Copilot AI changed the title [WIP] Add ReadMany API to Cosmos DB SDK Add ReadMany API to ContainerClient for batch item reads Oct 28, 2025
Copilot AI requested a review from analogrelay October 28, 2025 17:11
Copilot finished work on behalf of analogrelay October 28, 2025 17:11
Copilot AI requested a review from analogrelay October 28, 2025 17:53
Copilot finished work on behalf of analogrelay October 28, 2025 17:53
Copy link
Member

@analogrelay analogrelay left a comment

Choose a reason for hiding this comment

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

@copilot Move the ReadMany-related types and the API itself to a new cosmos_read_many.go file.

Copy link
Contributor Author

Copilot AI commented Oct 28, 2025

@copilot Move the ReadMany-related types and the API itself to a new cosmos_read_many.go file.

Moved ItemIdentity, ReadManyOptions, ReadManyResponse types and the ReadMany method to new cosmos_read_many.go file. Cleaned up unnecessary imports from cosmos_container.go. (48a3b34)

Copilot finished work on behalf of analogrelay October 28, 2025 18:06
Copilot AI requested a review from analogrelay October 28, 2025 18:06
@analogrelay
Copy link
Member

/azp run go - azcosmos

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

2 participants