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

[Draft] proposal: state API spec #5

Closed
seeflood opened this issue May 11, 2022 · 9 comments
Closed

[Draft] proposal: state API spec #5

seeflood opened this issue May 11, 2022 · 9 comments

Comments

@seeflood
Copy link
Member

seeflood commented May 11, 2022

1. What

Write a spec for state API and describe how to implement it in grpc, http1.1 and http2 and even in-process invocation.

2. Spec

// TODO

3. Recommended implementation

gRPC

The existing proto file is the recommended implementation in gRPC.
dapr/dapr#4603

in-process invocation

The trick here is that we can compile the proto file into interfaces in different programming language.
And these generated interfaces are "recommended implementation of in-process invocation".

in golang

The generated interface is the recommended implementation:

type DaprServer interface {
	// Invokes a method on a remote Dapr app.
	InvokeService(context.Context, *InvokeServiceRequest) (*v1.InvokeResponse, error)
	// Gets the state for a specific key.
	GetState(context.Context, *GetStateRequest) (*GetStateResponse, error)
	// Gets a bulk of state items for a list of keys
	GetBulkState(context.Context, *GetBulkStateRequest) (*GetBulkStateResponse, error)
}

The reason we don't use the client interface is that it has too many opts ...grpc.CallOption, which are useless for in-process communication

type DaprClient interface {

	// Gets the state for a specific key.
	GetState(ctx context.Context, in *GetStateRequest, opts ...grpc.CallOption) (*GetStateResponse, error)
	// Gets a bulk of state items for a list of keys
	GetBulkState(ctx context.Context, in *GetBulkStateRequest, opts ...grpc.CallOption) (*GetBulkStateResponse, error)
	// Saves the state for a specific key.
	SaveState(ctx context.Context, in *SaveStateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// Queries the state.
	QueryStateAlpha1(ctx context.Context, in *QueryStateRequest, opts ...grpc.CallOption) (*QueryStateResponse, error)
	// Deletes the state for a specific key.
	DeleteState(ctx context.Context, in *DeleteStateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// Deletes a bulk of state items for a list of keys
	DeleteBulkState(ctx context.Context, in *DeleteBulkStateRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
	// Executes transactions for a specified store
	ExecuteStateTransaction(ctx context.Context, in *ExecuteStateTransactionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
}

in java

The default protoc compiler can't compile proto files into java interfaces. We can modify the protoc compiler plugin to do it.

http 1.1

// TODO

@seeflood seeflood changed the title [Draft] State API spec [Draft] proposal: state API spec May 11, 2022
@seeflood
Copy link
Member Author

cc @beiwei30 @kevinten10

@kevinten10
Copy link

I also think that the simple interface is more conducive to becoming the standard API.

in-process invocation
The trick here is that we can compile the proto file into interfaces in different programming language.
And these generated interfaces are "recommended implementation of in-process invocation".

Developing proto plugins is more complicated.

In other words, if everyone agrees with this design idea.

At present, It is also possible for us to manually maintain a set of interface in each language.

Just like dapr-sdk does:

@beiwei30
Copy link
Member

I failed to get the reason why an "in-process invocation" API is necessary. Should we focus on API talking gRPC and HTTP? After all, these APIs are used between dapr sidecar and main app.

@yaron2
Copy link
Member

yaron2 commented Jun 29, 2022

I failed to get the reason why an "in-process invocation" API is necessary. Should we focus on API talking gRPC and HTTP? After all, these APIs are used between dapr sidecar and main app.

Agree

@salaboy
Copy link
Contributor

salaboy commented May 28, 2023

@seeflood @kevinten10 is there someone still actively working on this? I might start doing some work around Open API spec for Dapr Components, I am reaching out to see if there is already work that I should take a look at

@seeflood
Copy link
Member Author

@salaboy Sorry for not updating, I'm busy with work recently and not working on this issue.
There are two related issues, maybe you have read them:
dapr/dapr#2817
#3

looking forward to your work!

@salaboy
Copy link
Contributor

salaboy commented Jun 19, 2023

I will restart this issue.. and submit a PR with a simple statestore OpenAPI v3 spec. I am interested in having a simple first version that we can test against daprd and improve iteratively

@yaron2
Copy link
Member

yaron2 commented Jun 19, 2023

I will restart this issue.. and submit a PR with a simple statestore OpenAPI v3 spec. I am interested in having a simple first version that we can test against daprd and improve iteratively

What about generating the OpenAPI spec from the Dapr protos?

@salaboy
Copy link
Contributor

salaboy commented Sep 7, 2023

I am closing this issue as we have a draft initial version for the state api in the repo. we can open a new issue to track progress on that spec file

@salaboy salaboy closed this as completed Sep 7, 2023
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

No branches or pull requests

5 participants