Skip to content

Small refactor of the heartbeat call.#18

Merged
rafusel merged 1 commit intoadd-heartbeatfrom
minor-heartbeat-refactor
Jun 3, 2021
Merged

Small refactor of the heartbeat call.#18
rafusel merged 1 commit intoadd-heartbeatfrom
minor-heartbeat-refactor

Conversation

@ChezCrawford
Copy link
Copy Markdown

No description provided.

Comment thread pkg/server/heartbeat.go
httpResp, err := hb.client.Do(req)
if err != nil {
return 0, err
if !common.IsSuccessResponse(httpResp, err) {
Copy link
Copy Markdown
Author

@ChezCrawford ChezCrawford Jun 3, 2021

Choose a reason for hiding this comment

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

Makes use of the common success check.

Comment thread pkg/server/heartbeat.go
}

func (hb *heartbeat) makeHeartbeatRequest() (int, error) {
func (hb *heartbeat) doHeartbeatRequest() (*heartbeatResponseBody, error) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Inner function is responsible for making the request and parsing the data. The outer function decides what to do with the resulting data (in this case, updating the heartbeat interval).

Copy link
Copy Markdown
Contributor

@rafusel rafusel left a comment

Choose a reason for hiding this comment

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

Makes sense to me! I like this better for sure

@rafusel rafusel merged commit e45c262 into add-heartbeat Jun 3, 2021
@rafusel rafusel deleted the minor-heartbeat-refactor branch June 3, 2021 16:14
rafusel added a commit that referenced this pull request Jun 4, 2021
* Add heartbeat initial commit.

* FIxing a few loose ends.

* Add max retry time.

* Add changing heartbeat value with response.

* Stop old ticker.

* Remove max retry time check.

* Generate heartbeat id on heartbeat start.

* Remove "indirect".

* Rename consts.

* Rename heartbeatFrequency to frequency.

* Change header.

* Move heartbeat interface to heartbeat file.

* Move error logging to beat().

* A bit more cleanup.

* Move userAgent to common.

* Move retry transport to common.

* Update heartbeat to use RetryTransport.

* Nitpicks.

* Small refactor of the heartbeat call. (#18)

* Make retry transport configurable.

* Configure transport without constructor.

Co-authored-by: Charlie Crawford <ccrawford@pagerduty.com>
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.

3 participants