dapr / js-sdk

Dapr SDK for Javascript
Apache License 2.0
194 stars 82 forks source link

State ETag support with HTTP protocol #540

Open heunghingwan opened 10 months ago

heunghingwan commented 10 months ago

Describe the proposal

State ETag support has been added in #476, but it is limited to the grpc protocol. When using the http protocol, the ETag cannot be obtained through the get function. Not sure how to change it in a backwards compatible way, may be with a new function like getWithMetadata?

shubham1172 commented 10 months ago

Hi @heunghingwan, the ETAG comes back in the response header which we seem to be ignoring/dropping. Only the response body is being returned as Key-Value pairs via get method.

To be backward compatible, I propose a new method getState that looks like this:

async getState(statestore: string, key: string, options?: Partial<StateGetOptions>): Promise<GetStateResponse> {};

type GetStateResponse = {
  key: string,
  value: KeyValueType;
  etag?: string;
};

We can also add a deprecation notice to get function and remove it eventually in the next major release.

shubham1172 commented 10 months ago

@XavierGeerinck what are your thoughts?

XavierGeerinck commented 10 months ago

maybe with getFullState or getWithMetadata (as proposed)

shubham1172 commented 10 months ago

After discussing with Xavier offline, I am also in favor of getWithMetadata since state.getState will be awkward to look at. In the next major release, we can deprecate getWithMetadata and add the same functionality to get.

dapr-bot commented 8 months ago

This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.