Skip to content

Address PR review comments (#2) - #3

Open
evt wants to merge 13 commits into
v0.1from
v0.2
Open

Address PR review comments (#2)#3
evt wants to merge 13 commits into
v0.1from
v0.2

Conversation

@evt

@evt evt commented Jun 14, 2023

Copy link
Copy Markdown
Owner

closes: #2

@evt evt self-assigned this Jun 14, 2023

type CreateOrUpdatePortStore interface {
CreateOrUpdatePort(ctx context.Context, port *store.Port) error
CreateOrUpdatePort(ctx context.Context, port *repository.Port) error

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don' understand why the command package uses a repository model? This by pass completely the core so tightly couple two packages outside core that should be swappable...
Assume that repository.Port is specific of a DB technology (sqlite, mongo, gRPC, etc) in fact this would be a good case for subpackages (/internal/repository/port/postgres/db.go if you allow for many repositories and for many implementations), so the command would need to change if repository change. To avoid this we always have driver and driven code (left and right) of the hexagon to depend on core models.

@evt evt Jun 14, 2023

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

yeah, that's what happens when you work on multiple codebases at once :) and show something not yet completed. I'll fix it, cheers

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I've pushed the changes. More details here.

@@ -1,28 +1,27 @@
package adapters_test
package repository_test

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why did you choose to have external test packages to the code package? Is this necessary?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I planned it to be an integration test, then changed for a unit one and forgot to change, thank you.

Comment thread internal/transport/http.go Outdated
"github.com/evt/port-api/internal/app/command"
"github.com/evt/port-api/internal/app/query"
"github.com/evt/port-api/internal/common/server"
"github.com/evt/port-api/internal/repository"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Similarly to my previous comment you are tightly coupling package transport to repository, this bypass completely the core, which nullify a large benefit of hexagonal architecture

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

fixed by moving sentinel errors to domain package, cheers

}

func PortToDomain(p *Port) (*domain.Port, error) {
func portStoreToDomain(p *Port) (*domain.Port, error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you must check that p is not nil, which has the potential of panic for nil pointer exception.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

right, thank you. Fixed + added unit tests.

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.

2 participants