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

datetime client #1

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open

datetime client #1

wants to merge 30 commits into from

Conversation

RawanMostafa08
Copy link
Contributor

Issue link: codescalersinternships/home#288
This PR implements the first version of a datetime client

cmd/main.go Outdated Show resolved Hide resolved
cmd/main.go Outdated Show resolved Hide resolved
baseUrl string
endpoint string
port string
contentType string

Choose a reason for hiding this comment

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

I don't think you need to store the content type in the client, the same client can be used to fetch more than one content type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is a matter of opinion as Abdulrahman told me that configs should have the data type so I did it this way, It was an argument to the function before

}

// NewClient takes the baseUrl, endpoint, port, content-type and timeout and returns a Client object
func NewClient(baseUrl string, endpoint string, port string, contentType string, timeout time.Duration) Client {

Choose a reason for hiding this comment

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

timeout should be an option with default value say 10s

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you mean by an option? you mean optional parameter? isn't this not supported in go?

Comment on lines +28 to +30
baseUrl: baseUrl,
endpoint: endpoint,
port: port,

Choose a reason for hiding this comment

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

you can create and store only the request url instead of storing this data

// GetTime creates and sends the request and uses the retry mechanism
// for maximum of 10 seconds before the request fails
// it then returns the time and an error if it failed to send for 10 seconds
func (c Client) GetTime() (time.Time, error) {

Choose a reason for hiding this comment

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

I think content type should be passed as an argument here

pkg/client.go Outdated Show resolved Hide resolved
pkg/client.go Outdated Show resolved Hide resolved
pkg/client_test.go Outdated Show resolved Hide resolved
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.

2 participants