Skip to content

Conversation

@Hosshii
Copy link
Member

@Hosshii Hosshii commented Feb 24, 2022

What this PR does / why we need it:
Define unregistered app cache to remove redis from dependency of pipd_api and web_api.
The implementation of cache is almost copy of ListUnregisteredApplications in web_api and ReportUnregisteredApplicationConfigurations in piped_api.

Which issue(s) this PR fixes:

rel #2865

Does this PR introduce a user-facing change?:

NONE

@pipecd-bot
Copy link
Collaborator

GO_LINTER

The golinter build is completed with FAILURE. The build will be triggered again when you push any other commits. Or you can trigger it manually by /golinter trigger command right now.

You can check the build log from here.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.55%. This pull request does not change code coverage.

@khanhtc1202
Copy link
Member

@Hosshii should run make gazelle after adding new files 👀

@Hosshii
Copy link
Member Author

Hosshii commented Feb 25, 2022

Thank you!
I fixed. PTAL

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.55%. This pull request does not change code coverage.

"github.com/pipe-cd/pipecd/pkg/redis"
)

type Cache interface {
Copy link
Member

Choose a reason for hiding this comment

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

Nice added 👍 But I think there is no reason to explicitly mention that it's a cache. How about renaming this interface as Store just like other InsightStore or CommandStore 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

At first I was going to use store, but I thought there was a difference between store, which is persistent, and cache, which is not. And since redis is not persistent, I thought it would be better to use cache.

Copy link
Member

Choose a reason for hiding this comment

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

I get your point! To me, something called Cache means that data in it can be fetched from another data source; in that case, this current data source is the only one we can use to get/store what we want. But you have a point too 😄 Happy to hear other opinions!

Copy link
Member Author

Choose a reason for hiding this comment

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

I now understand your point of view. It is true that store seems more appropriate in that sense. Also, it might be better in terms of unity with the others.

Copy link
Collaborator

@pipecd-bot pipecd-bot left a comment

Choose a reason for hiding this comment

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

GO_LINTER

Some issues were detected while linting go source files in your changes.

}
}

func (c *store) ListUnregisteredApplications(ctx context.Context, projectID string) ([]*model.ApplicationInfo, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ctx is unused in ListUnregisteredApplications

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.55%. This pull request does not change code coverage.


if err != nil {
c.logger.Error("failed to get unregistered apps", zap.Error(err))
return nil, status.Error(codes.Internal, "Failed to get unregistered apps")
Copy link
Member

Choose a reason for hiding this comment

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

gRPC error is a special error type used for gRPC communication so it should only be returned by gRPC services such as web-api, piped-api. All other internal packages return only the normal error then the callers (web-api, ...) have to convert them to gRPC error.

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.55%. This pull request does not change code coverage.

@Hosshii
Copy link
Member Author

Hosshii commented Feb 28, 2022

I fixed.
PTAL

@nghialv
Copy link
Member

nghialv commented Feb 28, 2022

Good job.
/lgtm

)

type Store interface {
ListUnregisteredApplications(ctx context.Context, projectID string) ([]*model.ApplicationInfo, error)
Copy link
Member

Choose a reason for hiding this comment

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

I think that ListApplications is better since this is under the directory of unregisterdappstore.
but it's up to you.

Copy link
Member

Choose a reason for hiding this comment

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

Right. Nice catch! 💯

Copy link
Member Author

Choose a reason for hiding this comment

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

I fixed this. PTAL


type Store interface {
ListUnregisteredApplications(ctx context.Context, projectID string) ([]*model.ApplicationInfo, error)
PutUnregisteredApplications(projectID, pipedID string, apps []*model.ApplicationInfo) error
Copy link
Member

Choose a reason for hiding this comment

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

This is also the same.

@pipecd-bot pipecd-bot removed the lgtm label Feb 28, 2022
@knanao
Copy link
Member

knanao commented Feb 28, 2022

Nice!
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by knanao.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants