-
Notifications
You must be signed in to change notification settings - Fork 3
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
fix: General fixes before public release. #9
Conversation
danmrichards
commented
Nov 12, 2021
•
edited
Loading
edited
- Tidies up error handling on the internal event loop
- Fixes type repetition on game.New func
- Added clarifying comment on internal processor readiness
- Event and InternalEvent are now type declarations instead of aliases (which are not meant for everyday use)
- Adds comments on event types and consts
- Export Event consts and add comments
- Query packages now return concrete structs instead of interface, "accept interfaces, return structs"
- Fixes error types that did not conform to the XXXError naming convention
- Adds some suggestions in TODOs
- Restructures application to place publicly usable code in the pkg directory.
- Adds SIGTERM to signal handler and an explanation on its usage.
- Refactors UDP binding to use a done channel instead of atomics
- Removes internalEvent type.
- Refactors internal event processor to use a done channel instead of capturing and replaying internal event on shutdown.
- TCP server now echos packets back to the client.
- Tidies up error handling on the internal event loop - Fixes type repetition on game.New func - Added clarifying comment on internal processor readiness - Event and InternalEvent are now type declarations instead of aliases (which are not meant for everyday use) - Adds comments on event types and consts - Export Event consts and add comments - Query packages now return concrete structs instead of interface, "accept interfaces, return structs" - Fixes error types that did not conform to the XXXError naming convention - Adds some suggestions in TODOs
@@ -14,18 +14,30 @@ import ( | |||
) | |||
|
|||
type ( | |||
EventType = int | |||
InternalEvent = int |
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.
@@ -40,7 +41,7 @@ var ( | |||
|
|||
// NewQueryResponder returns creates a new responder capable of responding | |||
// to a2s-formatted queries. | |||
func NewQueryResponder(state *proto.QueryState) (proto.QueryResponder, error) { | |||
func NewQueryResponder(state *proto.QueryState) (*QueryResponder, error) { |
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.
Generally, it's good practice to accept interfaces and return structs. Interfaces are there to assert behaviour on a given type, which is generally in the domain of the thing accepting the type. Also, it makes this package easier to test, particularly if it had internal methods not part of that interface.
// ErrUnsupportedQuery is an error which represents an invalid SQP query header. | ||
ErrUnsupportedQuery struct { | ||
// UnsupportedQueryError is an error which represents an invalid SQP query header. | ||
UnsupportedQueryError 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.
…irectory. - Adds SIGTERM to signal handler and an explanation on its usage. - Refactors UDP binding to use a done channel instead of atomics - Removes internalEvent type. -Refactors internal event processor to use a done channel instead of capturing and replaying internal event on shutdown. - TCP server now echos packets back to the client.
2f172ca
to
dd9ab69
Compare
dd9ab69
to
f6c56a5
Compare
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.
Looks good, one nit - would loadConfig
do better in the config
package now as something like NewConfigFromFile()
?
Moves configuration loading to the public config package
Good shout, done |