Skip to content

Add heartbeat#17

Merged
rafusel merged 22 commits intomainfrom
add-heartbeat
Jun 4, 2021
Merged

Add heartbeat#17
rafusel merged 22 commits intomainfrom
add-heartbeat

Conversation

@rafusel
Copy link
Copy Markdown
Contributor

@rafusel rafusel commented May 18, 2021

No description provided.

@rafusel rafusel marked this pull request as ready for review May 19, 2021 20:01
Comment thread go.mod Outdated
Comment thread pkg/server/heartbeat.go Outdated
Comment thread pkg/server/heartbeat.go Outdated
Comment thread pkg/server/server.go Outdated
Status(string) ([]persistentqueue.StatusItem, error)
}

type Heartbeat interface {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We can probably clean this up a bit by moving this interface into heartbeat.go and having the constructor return the interface like: func NewHeartbeatTask() Heartbeat { ... }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've been seeing this "accept interfaces, return structs" thing in different posts so I moved the interface to heartbeat.go and then changed the HeartbeatTask struct to heartbeat. Let me know if I'm complete misunderstanding what you're saying, but here's my attempt at addressing the feedback: d615a10

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ah I see this as a case of generality:

If a type exists only to implement an interface and will never have exported methods beyond that interface, there is no need to export the type itself. Exporting just the interface makes it clear the value has no interesting behavior beyond what is described in the interface.

Comment thread pkg/server/heartbeat.go Outdated
Comment thread pkg/server/heartbeat.go Outdated
Comment thread pkg/server/heartbeat.go Outdated
Comment thread pkg/server/heartbeat.go Outdated
Copy link
Copy Markdown

@ChezCrawford ChezCrawford left a comment

Choose a reason for hiding this comment

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

I think this looks good for an initial implementation.

As I was completing this review I realized that it would probably make sense for us to use RetryTransport here since it already has solid HTTP retry logic built into it. Rather than delaying this we can cut a separate ticket to come back and replace this.

@rafusel rafusel requested a review from ChezCrawford June 2, 2021 20:49
Copy link
Copy Markdown

@ChezCrawford ChezCrawford left a comment

Choose a reason for hiding this comment

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

This looks good @rafusel.

Before you merge:

  • have a look at one tiny PR I put up into this branch: https://github.com/PagerDuty/go-pdagent/pull/18/files that is a small refactor to the heartbeat HTTP call. I left a few comments about why I think it is slightly cleaner.

  • Squash everything down to a single commit.

@rafusel rafusel requested a review from ChezCrawford June 3, 2021 17:23
@rafusel rafusel merged commit f0ffe67 into main Jun 4, 2021
@rafusel rafusel deleted the add-heartbeat branch June 4, 2021 17:34
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