-
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
Initial implementaion of the Datetime client #1
base: main
Are you sure you want to change the base?
Conversation
… and port along with testing
…time from different servers with different content types
…ent structured logging
…ing, building and containerization
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main |
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.
on push
.github/workflows/ci-pipeline.yml
Outdated
- main | ||
|
||
jobs: | ||
golangci: |
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.
lint
README.md
Outdated
# DateTime Client | ||
|
||
This project implements a client for fetching date and time information from two different server types: a standard HTTP server and a Gin server. The client supports both JSON and plain text responses. |
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.
the client should fetch date/time from any server exposing the api, not caring that the server is built with http or gin, no?
main.go
Outdated
serverURL := os.Getenv("SERVER_URL") | ||
serverPort := os.Getenv("SERVER_PORT") | ||
serverPortGin := os.Getenv("SERVER_PORT_GIN") | ||
|
||
if serverURL == "" || serverPort == "" || serverPortGin == "" { | ||
log.Fatal("SERVER_URL, SERVER_PORT, and SERVER_PORT_GIN must be set") | ||
} | ||
|
||
client.SetupEnv(serverURL, serverPort, serverPortGin) |
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.
why not using flags with default values
main.go
Outdated
serverPort := os.Getenv("SERVER_PORT") | ||
serverPortGin := os.Getenv("SERVER_PORT_GIN") |
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.
I don't think this should be done, the client should fetch data from whatever server, so no need to force the server to fetch data from both servers every time
main.go
Outdated
serverTypes := []string{"standard", "gin"} | ||
contentTypes := []string{"application/json", "text/plain"} | ||
|
||
for _, serverType := range serverTypes { |
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.
I think the client can take an argument representing the response type, and then you can use it to fetch the date and time with the required format so your client can be more generic
main.go
Outdated
log.Fatal("SERVER_URL, SERVER_PORT, and SERVER_PORT_GIN must be set") | ||
} | ||
|
||
client.SetupEnv(serverURL, serverPort, serverPortGin) |
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.
why should you set env here? the variables should be already set at this point
client/client.go
Outdated
// | ||
// The function uses an exponential backoff retry mechanism for failed requests. | ||
func GetDateTime(serverType, contentType string) (string, error) { | ||
serverURL := os.Getenv("SERVER_URL") |
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.
there can be a client holding the needed values needed to get the data instead of fetching them over and over again
…tion and Updating Makefile, Docker, and Documentation accordingly
DateTime Client Implementation
This PR introduces a Go-based DateTime Client with the following features:
Key Components:
Client Implementation (
client.go
)Error Handling (
errors.go
)Main Application (
main.go
)Dockerfile
Makefile
README.md
This PR sets up the complete DateTime Client project, ready for review and integration.