-
Notifications
You must be signed in to change notification settings - Fork 172
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
Add support for Dapr InvokeService and InvokeBinding API #362
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4b948b1
support dapr InvokeService and InvokeBinding API
seeflood f330529
add doc
seeflood 0939adf
fix ut and dependencies
seeflood 903563e
add ut
seeflood 572f58f
remove dependency on dapr/dapr
seeflood 1cac425
fix ut compilation error
seeflood 29feae4
ignore pb in codecov
seeflood 2e933b3
test HttpExtension
seeflood 0b05513
test NewDaprAPI_Alpha
seeflood 62da459
move unimplement methods to a new file
seeflood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright 2021 Layotto Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package utils | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func Test_addPathSeparator(t *testing.T) { | ||
p := addPathSeparator("") | ||
assert.Equal(t, p, "/") | ||
p = addPathSeparator("l8") | ||
assert.Equal(t, p, "/l8/") | ||
p = addPathSeparator("/l8") | ||
assert.Equal(t, p, "/l8/") | ||
p = addPathSeparator("l8/") | ||
assert.Equal(t, p, "/l8/") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## TLDR | ||
本提案想让开源Layotto 既支持 Layotto API,又支持Dapr API。类似于“Minio 既支持Minio API,又支持AWS S3 API” | ||
|
||
## 想解决的问题 | ||
1. 目前,我们尽量保证Layotto API 里各个字段定义的和Dapr一样,但用户真正关心的是两者sdk能否复用。虽然我们努力保证proto字段一致,但只要不能复用sdk就没解决用户的问题,还给自己增加维护成本。 | ||
比如: | ||
![image](https://user-images.githubusercontent.com/26001097/145837477-00fc5cd8-32eb-4ce9-bbfb-6e590172fce8.png) | ||
|
||
因此,我们想让Layotto直接支持Dapr的grpc API (一模一样,包括 package名),对于用户来说,他可以用Dapr sdk在两者之间自由切换,不用担心被厂商绑定。 | ||
|
||
2. 另一方面,还需要有一定扩展性。我们在生产落地的过程中发现目前的Dapr API没法完全满足需求,难免要对API做一些扩展。扩展的API已经加到了现在的 Layotto API里,提案提给了 Dapr 社区、但还在等社区慢慢接受,比如config API,比如Lock API | ||
|
||
## 方案 | ||
### Layotto API on Dapr API | ||
![image](https://user-images.githubusercontent.com/26001097/145838604-e3a0caad-9473-4092-a2c6-0cc46c972790.png) | ||
1. Layotto 会启动一个grpc服务器,前阵子刚加了个API插件功能,我们可以通过 API插件的形式注册一个Dapr API 插件; | ||
2. 另一方面,保留Layotto API。Layotto接收到Layotto API请求后,翻译成Dapr API,然后按Dapr API处理。 | ||
这样的好处有: | ||
- 复用代码 | ||
- Layotto API 可以按生产需求进行扩展,比如支持Lock API,configuration API等;做了扩展后可以提给Dapr 社区,再慢慢讨论,即使最终讨论的结果和原始方案不一样,也只是影响最终做出来的Dapr API,不会影响已经用上Layotto API的用户。 | ||
|
||
### 用户价值 | ||
对于用户来说: | ||
|
||
- 如果用户担心厂商绑定,可以只用Dapr API,可以用同一套Dapr sdk在Dapr 和Layotto 之间迁移,减少用户疑虑; | ||
- 如果用户相信我们的落地经验、愿意用Layotto API,那他们可以用Layotto API,代价是没法用同一个sdk在两个sidecar之间迁移 | ||
|
||
### Q&A | ||
#### 想给Dapr API加字段怎么加 | ||
##### 想加个字段(field) | ||
比如想给layotto api加个abc字段,可以通过metadata或者grpc头把这个字段传给dapr API | ||
dapr API的实现再把这个字段透传给组件,组件解析这个字段 | ||
|
||
##### 不只加字段,还要加一些逻辑、机制(mechanism) | ||
比如layotto api加个abc字段,如果abc==true,那么runtime走一段特殊逻辑 | ||
|
||
这种情况要修改Dapr API的实现,加一段if else | ||
|
||
#### 想加新API怎么加 | ||
加在layotto API上,新API不需要复用Dapr API;等Dapr接收提案后再修改实现,layotto API不变 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there no test logic related to etcd, as this file is actually etcd_test.go?