-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
|
} | ||
|
||
func run() error { | ||
return http.ListenAndServe(":8081", www.NewService()) |
There was a problem hiding this comment.
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
},
}
There was a problem hiding this comment.
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.
"github.com/go-chi/chi/v5" | ||
) | ||
|
||
type Service struct { |
There was a problem hiding this comment.
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.
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
Semantic Versioning
feat
changeType of change
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: