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

[SCB-1398] add project in uri path, modify related api to support the change #25

Merged
merged 5 commits into from Aug 14, 2019

Conversation

liuqi04
Copy link
Contributor

@liuqi04 liuqi04 commented Aug 9, 2019

[SCB-1398]

  1. add project field in KVDoc and LabelDoc, add the param for project in backend api
  2. all related mongo CRUD ops should add filter for param project
  3. modify swagger yaml file

client/client.go Outdated
url := fmt.Sprintf("%s/%s/%s", c.opts.Endpoint, APIPathKV, kv.Key)
func (c *Client) Put(ctx context.Context, kv model.KVDoc, project string) (*model.KVDoc, error) {
finalPath := fmt.Sprintf("%s/%s/%s", version, project, APIPathKV)
url := fmt.Sprintf("%s/%s/%s", c.opts.Endpoint, finalPath, kv.Key)
Copy link
Contributor

Choose a reason for hiding this comment

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

fmt.Sprintf is graceful, but it has poor performance, never use it in func that handles a lots of data

1. add project field in KVDoc and LabelDoc, add the param for project in backend api
2. all related mongo CRUD should add filter for project
client/client.go Outdated
@@ -81,8 +82,9 @@ func New(config Config) (*Client, error) {
}

//Put create value of a key
func (c *Client) Put(ctx context.Context, kv model.KVDoc) (*model.KVDoc, error) {
url := fmt.Sprintf("%s/%s/%s", c.opts.Endpoint, APIPathKV, kv.Key)
func (c *Client) Put(ctx context.Context, kv model.KVDoc, project string) (*model.KVDoc, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

project is an option, default value is "default"

client/client.go Outdated
@@ -113,12 +115,13 @@ func (c *Client) Put(ctx context.Context, kv model.KVDoc) (*model.KVDoc, error)
}

//Get get value of a key
func (c *Client) Get(ctx context.Context, key string, opts ...GetOption) ([]*model.KVDoc, error) {
func (c *Client) Get(ctx context.Context, key string, project string, opts ...GetOption) ([]*model.KVDoc, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

project is an option, default value is "default"

client/client.go Outdated
@@ -147,8 +150,9 @@ func (c *Client) Get(ctx context.Context, key string, opts ...GetOption) ([]*mod
}

//Delete remove kv
func (c *Client) Delete(ctx context.Context, kvID, labelID string) error {
url := fmt.Sprintf("%s/%s/?kvID=%s", c.opts.Endpoint, APIPathKV, kvID)
func (c *Client) Delete(ctx context.Context, kvID, labelID string, project string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

project is an delete option, default value is "default"

client/client.go Outdated
@@ -35,7 +35,7 @@ import (

//const
const (
APIPathKV = "v1/kv"
APIPathKV = "v1/test/kie/kv"
Copy link
Contributor

Choose a reason for hiding this comment

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

test is dead code

@@ -70,6 +71,11 @@ func (r *KVResource) GetByKey(context *restful.Context) {
WriteErrResponse(context, http.StatusForbidden, "key must not be empty", common.ContentTypeText)
return
}
project := context.ReadPathParameter("project")
Copy link
Contributor

Choose a reason for hiding this comment

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

you read it twice

@tianxiaoliang tianxiaoliang merged commit ad07721 into apache:master Aug 14, 2019
@liuqi04 liuqi04 deleted the tmp branch August 15, 2019 10:28
@liuqi04 liuqi04 changed the title add project in uri path, modify related api to support the change [SCB-1398] add project in uri path, modify related api to support the change Aug 15, 2019
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.

None yet

2 participants