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

chore(graph): add traverse methods container start and shutdown #5508

Merged
merged 14 commits into from
Dec 6, 2023

Conversation

KollaAdithya
Copy link
Contributor

This Is part3 for implementation of essential and dependsOn

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.

@KollaAdithya KollaAdithya requested a review from a team as a code owner November 30, 2023 01:05
@KollaAdithya KollaAdithya requested review from Lou1415926 and removed request for a team November 30, 2023 01:05
Copy link

github-actions bot commented Nov 30, 2023

🍕 Here are the new binary sizes!

Name New size (kiB) size (kiB) Delta (%)
macOS (amd) 56768 55192 🥺 +2.86
macOS (arm) 57764 56144 🥺 +2.89
linux (amd) 49776 48440 🥺 +2.76
linux (arm) 49088 47748 🥺 +2.81
windows (amd) 46904 45672 🥺 +2.70

@KollaAdithya KollaAdithya changed the title chore: add traverse methods container start and shutdown chore(graph): add traverse methods container start and shutdown Nov 30, 2023
@codecov-commenter
Copy link

codecov-commenter commented Nov 30, 2023

Codecov Report

Attention: 53 lines in your changes are missing coverage. Please review.

Comparison is base (90633d5) 70.00% compared to head (e6e30ba) 70.05%.
Report is 6 commits behind head on mainline.

Files Patch % Lines
internal/pkg/graph/graph.go 86.71% 12 Missing and 5 partials ⚠️
internal/pkg/cli/errors.go 14.28% 12 Missing ⚠️
internal/pkg/docker/orchestrator/orchestrator.go 56.25% 6 Missing and 1 partial ⚠️
internal/pkg/cli/init.go 0.00% 5 Missing ⚠️
internal/pkg/cli/deploy/lbws.go 0.00% 4 Missing ⚠️
internal/pkg/cli/run_local.go 92.85% 2 Missing and 1 partial ⚠️
internal/pkg/describe/env.go 0.00% 3 Missing ⚠️
internal/pkg/cli/svc_deploy.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           mainline    #5508      +/-   ##
============================================
+ Coverage     70.00%   70.05%   +0.04%     
============================================
  Files           302      302              
  Lines         46169    46325     +156     
  Branches        309      309              
============================================
+ Hits          32321    32453     +132     
- Misses        12276    12294      +18     
- Partials       1572     1578       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -17,6 +24,8 @@ const (
type Graph[V comparable] struct {
vertices map[V]neighbors[V] // Adjacency list for each vertex.
inDegrees map[V]int // Number of incoming edges for each vertex.
status map[V]string // status of each vertex.
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a little odd for a generic graph to have a "status" field. Maybe consider creating a more specific struct and inherit from Graph[V comparable] in this pkg? This way we can also consolidate graphTraversal which is already very deeply coupled with this struct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just created a new LabeledGraph[V comparable] which inherits *Graph[V] that would reduce the coupling between Graph[V comparable].
Does this address the concern on coupling and generic graph to have a "status" field 🤔

@@ -17,6 +24,8 @@ const (
type Graph[V comparable] struct {
vertices map[V]neighbors[V] // Adjacency list for each vertex.
inDegrees map[V]int // Number of incoming edges for each vertex.
status map[V]string // status of each vertex.
lock sync.Mutex // lock used to mutate graph data.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need a lock in the graph struct instead of defining it in the caller? It doesn't seem we apply the lock to all methods to make this struct truly atomic...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I modified the code where every method of LabeledGraph[V comparable] struct uses lock .

Couple of reasons why i want to use lock declaring over here instead of caller.

  1. If the lock is managed within the data structure, it simplifies the usage for the caller. The caller does not need to worry about acquiring and releasing the lock, making the API easier to use
  2. The caller may not have full context or understanding of the graph's internals, which increases the risk of incorrect or insufficient locking, leading to potential data races or deadlocks.

internal/pkg/graph/graph.go Outdated Show resolved Hide resolved
internal/pkg/graph/graph.go Show resolved Hide resolved
Copy link
Contributor

@CaptainCarpensir CaptainCarpensir left a comment

Choose a reason for hiding this comment

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

Looks good, just some inconsequential nits

internal/pkg/graph/graph_test.go Outdated Show resolved Hide resolved
internal/pkg/deploy/pipeline.go Outdated Show resolved Hide resolved
Copy link
Contributor

@iamhopaul123 iamhopaul123 left a comment

Choose a reason for hiding this comment

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

:shipit:

internal/pkg/graph/graph.go Outdated Show resolved Hide resolved
@iamhopaul123 iamhopaul123 added the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Dec 6, 2023
@KollaAdithya KollaAdithya removed the do-not-merge Pull requests that mergify shouldn't merge until the requester allows it. label Dec 6, 2023
@mergify mergify bot merged commit bafc52c into aws:mainline Dec 6, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants