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

@ff/server v0.0.1 #18

Closed
wants to merge 4 commits into from
Closed

@ff/server v0.0.1 #18

wants to merge 4 commits into from

Conversation

adoublef
Copy link
Contributor

@adoublef adoublef commented Aug 3, 2022

Description

This is for the service scaffolding. Using this as a template for building a service struct which is easily extendable. Currently there are no dependencies (no databases) but can easily be added at a time we see fit

Fixes #1 (issue)

Current status

  • Waiting for review
  • Waiting for comment resolution
  • Waiting for merge
  • Draft
  • Trivial PR (nominal cosmetic/typo/whitespace changes)

Semantic Versioning

  • This is a feat change

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

I have used this as a basis for testing http services in Go. all checks pass (status 501) with 84% coverage

Manual

Checklist:

  • My commit message mentions fix, feat, BREAKING CHANGE accordingly to increase the semantic versioning
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have checked my code/docs and corrected any misspellings

@adoublef
Copy link
Contributor Author

adoublef commented Aug 3, 2022

golangcli-lint fails due to two unused helper functions related to decoding json messages and the cmd/server/main.go not handling error

hansvb
hansvb previously approved these changes Aug 3, 2022
}

func run() error {
return http.ListenAndServe(":8081", www.NewService())
Copy link
Contributor

@pmoieni pmoieni Aug 3, 2022

Choose a reason for hiding this comment

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

add graceful shutdown and define a stdlib server struct like this to handle timeout and idle situations:

server := http.Server{
   	Addr:         s.Port,
   	Handler:      handler,
   	ErrorLog:     log.Default(),     // set the logger for the server
   	ReadTimeout:  10 * time.Second,  // max time to read request from the client
   	WriteTimeout: 10 * time.Second,  // max time to write response to the client
   	IdleTimeout:  120 * time.Second, // max time for connections using TCP Keep-Alive
   	BaseContext: func(_ net.Listener) context.Context {
   		return serverCtx
   	},
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

graceful shutdown can be added here, may use a builder pattern as timeouts may be configurable from command line.

www/routes.go Show resolved Hide resolved
www/routes.go Show resolved Hide resolved
"github.com/go-chi/chi/v5"
)

type Service struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Service is a general name. use a more specific name like JamService. because not all of the services are gonna have the same struct types and parameters.

@hansvb hansvb dismissed their stale review August 4, 2022 05:49

It contains more than we want in v0.0.1

@harveysanders harveysanders deleted the @ff/server-v0.0.1 branch September 22, 2022 11:25
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.

Scaffold Application Server
4 participants