Skip to content

Conversation

@hokandil
Copy link
Contributor

Description

I added a new output binding to support graph DB in Azure Cosmos via the Gremlin API.
unfortunately there no issue reference for this PR , although I found it useful to share this with you.

Please make sure you've completed the relevant tasks for this PR, out of the following list:

@ghost
Copy link

ghost commented May 25, 2021

CLA assistant check
All CLA requirements met.

@yaron2 yaron2 requested a review from beiwei30 June 4, 2021 02:55
@yaron2
Copy link
Member

yaron2 commented Jun 4, 2021

@beiwei30 can you please review?

@hokandil
Copy link
Contributor Author

hokandil commented Jun 4, 2021

@beiwei30 I fixed the issue causing the golangci-lint to fail.

Copy link
Contributor

@halspang halspang left a comment

Choose a reason for hiding this comment

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

Couple sections of commented code, let's remove it if we don't need it or put it back if we do.

Comment on lines 43 to 44
// NumMaxActiveConnections string `json:"NumMaxActiveConnections"`
// ConnectionIdleTimeout string `json:"ConnectionIdleTimeout"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we not want to use these and give defaults if they aren't provided?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, @halspang you are right , some comments need to be removed along with these values (NumMaxActiveConnections, ConnectionIdleTimeout) , I felt like it is over complicating the component YAML file , so I decided to remove it . any way the gremcos package assign there values to a default values which is more than enough for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All unwanted comment removed.

@hokandil hokandil requested a review from halspang June 9, 2021 09:14
@yaron2
Copy link
Member

yaron2 commented Jun 27, 2021

@hokandil please resolve the conflicts and we'll assign a reviewer.

@hokandil
Copy link
Contributor Author

@yaron2 Done, conflicts resolved , thank you

@yaron2
Copy link
Member

yaron2 commented Jun 27, 2021

@halspang can you please review this?

Copy link
Contributor

@halspang halspang left a comment

Choose a reason for hiding this comment

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

Changes look good to me, just some small last things.

@yaron2 is passing the query though metadata the standard? If so, what's the reasoning behind it? I'm fine with it if that's the case, just curious.

@hokandil hokandil requested a review from halspang June 29, 2021 16:44
@yaron2
Copy link
Member

yaron2 commented Jul 8, 2021

@hokandil I left two comments. kindly fix those, and resolve the linter issue:

Check failure on line 53 in bindings/azure/cosmosgraphdb/cosmosgraphdb.go

GitHub Actions
/ Build linux_amd64 binaries
bindings/azure/cosmosgraphdb/cosmosgraphdb.go#L53
File is not `gofmt`-ed with `-s` (gofmt)

Then we can merge :)

@yaron2
Copy link
Member

yaron2 commented Jul 12, 2021

@hokandil ping

@hokandil
Copy link
Contributor Author

@yaron2 I am on testing phase, I will commit shortly , maybe tomorrow .

@hokandil hokandil requested review from a team as code owners July 13, 2021 17:46
@hokandil
Copy link
Contributor Author

@yaron2 Done

Copy link
Member

@pkedy pkedy left a comment

Choose a reason for hiding this comment

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

Just pointing out a few potential improvements.

}

func (c *CosmosGraphDB) parseMetadata(metadata bindings.Metadata) (*cosmosGraphDBCredentials, error) {
b, err := json.Marshal(metadata.Properties)
Copy link
Member

Choose a reason for hiding this comment

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

return nil, errors.New("CosmosGraphDB Error: Cannot convert request data")
}

gq := fmt.Sprintf("%s", jsonPoint[commandGremlinKey])
Copy link
Member

Choose a reason for hiding this comment

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

Nit: It might more sense to unmarshal into an inline struct instead of map[string]interface{} since you know the field you expect.

type gremlinData struct {
  Gremlin string `json:"gremlin"` // Note sure if this is always a string, use `interface{}` otherwise.
}
var jsonPoint gremlinData

Also, using %v might make more since for an interface{} going in. But again, if the value is always going to be a string then the fmt.Sprintf is unnecessary.

gq := fmt.Sprintf("%v", jsonPoint[commandGremlinKey])

@hokandil hokandil requested review from yaron2 and removed request for a team July 14, 2021 09:55
@yaron2 yaron2 mentioned this pull request Jul 14, 2021
6 tasks
@codecov
Copy link

codecov bot commented Jul 14, 2021

Codecov Report

Merging #885 (83e9716) into master (01147e5) will increase coverage by 3.61%.
The diff coverage is 37.41%.

❗ Current head 83e9716 differs from pull request most recent head b366e1a. Consider uploading reports for the commit b366e1a to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #885      +/-   ##
==========================================
+ Coverage   30.59%   34.21%   +3.61%     
==========================================
  Files          85      133      +48     
  Lines        7148    10595    +3447     
==========================================
+ Hits         2187     3625    +1438     
- Misses       4724     6591    +1867     
- Partials      237      379     +142     
Impacted Files Coverage Δ
bindings/alicloud/oss/oss.go 11.11% <ø> (ø)
bindings/alicloud/rocketmq/rocketmq.go 0.00% <0.00%> (ø)
bindings/apns/apns.go 88.00% <ø> (ø)
bindings/aws/dynamodb/dynamodb.go 10.52% <ø> (ø)
bindings/aws/kinesis/kinesis.go 2.61% <ø> (ø)
bindings/aws/s3/s3.go 10.81% <ø> (ø)
bindings/aws/sns/sns.go 10.52% <ø> (ø)
bindings/aws/sqs/sqs.go 6.55% <0.00%> (ø)
bindings/azure/blobstorage/blobstorage.go 7.54% <0.00%> (-0.30%) ⬇️
bindings/azure/cosmosdb/cosmosdb.go 25.71% <ø> (ø)
... and 173 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3730993...b366e1a. Read the comment docs.

@yaron2 yaron2 merged commit 13f96c4 into dapr:master Jul 14, 2021
Taction added a commit to Taction/components-contrib that referenced this pull request Jul 15, 2021
* master: (23 commits)
  Adds support for TTL in Redis State Store (dapr#990)
  Adds support for TTL in Memcached State Store (PR Fixup) (dapr#1011)
  Adds support for TTL in Cassandra State Store (dapr#996)
  Return blob metadata and add list operation (dapr#999)
  Added new output binding for Cosmos Graph DB - Gremlin (dapr#885)
  Adds support for TTL in CosmosDB State Store (dapr#991)
  Delete unused code and update test (dapr#924)
  Return SystemProperties on events from EventHubs bindings and pubsub (dapr#1009)
  Implement E2E tests for zeebe (dapr#973)
  rebase (dapr#982)
  Update CODEOWNERS (dapr#987)
  ci: add test skip case (dapr#922)
  fix: Mysql should support more data types. dapr#923 (dapr#926)
  fix: Dapr runtime panic when handle Pub/Sub (dapr#3281) (dapr#967)
  switch to golang-jwt (dapr#993)
  unmarshal getBlobRetryCount as int (dapr#919)
  secretstores: support more format of azure key vault (dapr#944)
  Optimize vault secret component error output (dapr#909)
  Convert AZURE_KEYVAULT in conformance.yml a GitHub secret (dapr#1002)
  Use AzureKeyVaultName param for Azure Keyvault conformance test (dapr#975)
  ...

# Conflicts:
#	secretstores/hashicorp/vault/vault.go
@artursouza artursouza modified the milestone: v1.5 Nov 10, 2021
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.

5 participants