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

feat(datastore): Add read time from client while running queries #11447

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

bhshkh
Copy link
Contributor

@bhshkh bhshkh commented Jan 14, 2025

Fixes: #11012

User can create a client with read time option. This option wasn't getting passed in RunQueryRequest and RunAggregationQueryRequest. This PR adds this option.

// The options for this query.
ReadOptions *ReadOptions `protobuf:"bytes,1,opt,name=read_options,json=readOptions,proto3" json:"read_options,omitempty"`

// The options for this query.
ReadOptions *ReadOptions `protobuf:"bytes,1,opt,name=read_options,json=readOptions,proto3" json:"read_options,omitempty"`

// The options shared by read requests.
type ReadOptions struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// For Cloud Firestore in Datastore mode, if you don't specify
// read_consistency then all lookups and queries default to
// `read_consistency`=`STRONG`. Note that, in Cloud Datastore, global queries
// defaulted to `read_consistency`=`EVENTUAL`.
//
// Explicitly setting `read_consistency`=`EVENTUAL` will result in eventually
// consistent lookups and queries.
//
// Types that are assignable to ConsistencyType:
//
// *ReadOptions_ReadConsistency_
// *ReadOptions_Transaction
// *ReadOptions_NewTransaction
// *ReadOptions_ReadTime
ConsistencyType isReadOptions_ConsistencyType `protobuf_oneof:"consistency_type"`
}

As can be seen in above proto, the consistency type field in ReadOptions can be one of ReadOptions_ReadConsistency_, ReadOptions_Transaction, ReadOptions_NewTransaction or ReadOptions_ReadTime. Same validation has been added on client

@bhshkh bhshkh requested review from a team as code owners January 14, 2025 01:01
@product-auto-label product-auto-label bot added the api: datastore Issues related to the Datastore API. label Jan 14, 2025
@bhshkh bhshkh requested a review from gkevinzheng January 14, 2025 01:09
datastore/query.go Outdated Show resolved Hide resolved
@bhshkh bhshkh changed the title fix(datastore): Add read time from client while running queries feat(datastore): Add read time from client while running queries Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

datastore: snapshot reads for GetAll queries
2 participants