Skip to content

[content-service] Refactor to use baseserver #9973

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

Merged
merged 1 commit into from
May 17, 2022

Conversation

easyCZ
Copy link
Member

@easyCZ easyCZ commented May 12, 2022

Description

Refactors content service to use baseserver for server setup. Removes scattered config and allows us to normalize server setup across components.

Related Issue(s)

Similar to #10005

How to test

Content service runs in preview, unit tests pass

Release Notes

NONE

Documentation

NONE

/hold

@easyCZ easyCZ changed the title [content-service] Port to use baseserver [content-service] Refactor to use baseserver May 12, 2022
@easyCZ easyCZ force-pushed the mp/content-service-baseserver branch 4 times, most recently from 445fb19 to 36dae42 Compare May 16, 2022 19:39
@easyCZ easyCZ changed the base branch from main to mp/baseserver-init-metrics May 16, 2022 19:40
@easyCZ easyCZ force-pushed the mp/content-service-baseserver branch from fdc536b to e4a8f25 Compare May 16, 2022 20:04
@easyCZ easyCZ force-pushed the mp/baseserver-init-metrics branch from d603efd to 73cb046 Compare May 17, 2022 05:18
Base automatically changed from mp/baseserver-init-metrics to main May 17, 2022 05:44
@easyCZ easyCZ force-pushed the mp/content-service-baseserver branch from 7c638e0 to bdba136 Compare May 17, 2022 05:55
@easyCZ easyCZ force-pushed the mp/content-service-baseserver branch from 2836760 to c671645 Compare May 17, 2022 06:17
@easyCZ
Copy link
Member Author

easyCZ commented May 17, 2022

From my testing on preview, this looks to be working but I'm lacking context on some flows which use the content service, so would appreciate help/direction on what needs to be validated.

@easyCZ easyCZ marked this pull request as ready for review May 17, 2022 06:36
@easyCZ easyCZ requested a review from a team May 17, 2022 06:36
@easyCZ easyCZ requested review from aledbf and sagor999 as code owners May 17, 2022 06:36
@easyCZ easyCZ requested a review from a team May 17, 2022 06:36
@easyCZ easyCZ requested a review from geropl as a code owner May 17, 2022 06:36
@github-actions github-actions bot added team: IDE team: workspace Issue belongs to the Workspace team labels May 17, 2022
Storage StorageConfig `json:"storage"`
}

type TLSConfig struct {
Copy link
Member Author

Choose a reason for hiding this comment

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

TLS config is now part of baseserver so using it directly.

Prometheus: config.Prometheus{
Addr: fmt.Sprintf(":%d", PrometheusPort),
},
PProf: config.PProf{
Copy link
Member Author

Choose a reason for hiding this comment

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

Wasn't used anywhere besides as a value passed into the server as config.

Service: config.Service{
Addr: fmt.Sprintf(":%d", RPCPort),
},
Prometheus: config.Prometheus{
Copy link
Member Author

Choose a reason for hiding this comment

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

There's a default metrics port for each baseserver so using that instead.

contentService, err := service.NewContentService(cfg.Storage)
if err != nil {
log.WithError(err).Fatalf("cannot create content service")
log.WithError(err).Fatalf("Cannot create content service")
Copy link
Contributor

Choose a reason for hiding this comment

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

please leave this lowercase. The vast majority of our error messages is lowercase, and we should keep things consistent

Copy link
Member Author

@easyCZ easyCZ May 17, 2022

Choose a reason for hiding this comment

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

General practice in Go (and elsewhere) is to uppercase logs to make them sentences. They are designed to be consumed by humans and first letter uppercase is slightly easier to visually grep. Even our style guide uses first letter uppercase in logs https://github.com/uber-go/guide/blob/master/style.md#reduce-nesting

The change here is really just a drive by improvement to be more consistent with general practice.

Errors, on the other hand, should never start with an uppercase because they get wrapped and composed so don't really form sentences.

Copy link
Member Author

Choose a reason for hiding this comment

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

Here's another reference from go code review style guide

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair point.

/hold cancel

Copy link
Contributor

@csweichel csweichel left a comment

Choose a reason for hiding this comment

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

Sans nit, lgtm

/hold

Copy link
Contributor

@mustard-mh mustard-mh left a comment

Choose a reason for hiding this comment

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

lgtm

@roboquat roboquat merged commit 6b11a82 into main May 17, 2022
@roboquat roboquat deleted the mp/content-service-baseserver branch May 17, 2022 18:22
@roboquat roboquat added the deployed: IDE IDE change is running in production label May 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: IDE IDE change is running in production release-note-none size/L team: IDE team: workspace Issue belongs to the Workspace team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants