Skip to content

Commit

Permalink
rename StatusIface interface to StatusReporter
Browse files Browse the repository at this point in the history
  • Loading branch information
pashagolub committed Jan 19, 2022
1 parent c299d87 commit 952442b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions internal/api/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ import (
"github.com/cybertec-postgresql/pg_timetable/internal/log"
)

// StatusIface is a common interface describing the current status of a connection
type StatusIface interface {
// StatusReporter is a common interface describing the current status of a connection
type StatusReporter interface {
IsReady() bool
}

type RestApiServer struct {
StatusReporter StatusIface
l log.LoggerIface
*http.Server
Reporter StatusReporter
l log.LoggerIface
http.Server
}

func Init(opts config.RestApiOpts, logger log.LoggerIface) *RestApiServer {
s := &RestApiServer{
nil,
logger,
&http.Server{
http.Server{
Addr: fmt.Sprintf(":%d", opts.Port),
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
Expand All @@ -44,7 +44,7 @@ func Init(opts config.RestApiOpts, logger log.LoggerIface) *RestApiServer {

func (Server *RestApiServer) readinessHandler(w http.ResponseWriter, r *http.Request) {
Server.l.Debug("Received /readiness REST API request")
if Server.StatusReporter == nil || !Server.StatusReporter.IsReady() {
if Server.Reporter == nil || !Server.Reporter.IsReady() {
w.WriteHeader(http.StatusServiceUnavailable)
return
}
Expand Down
2 changes: 1 addition & 1 deletion internal/api/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestStatus(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, http.StatusServiceUnavailable, r.StatusCode)

restsrv.StatusReporter = &reporter{}
restsrv.Reporter = &reporter{}
r, err = http.Get("http://localhost:8080/readiness")
assert.NoError(t, err)
assert.Equal(t, http.StatusOK, r.StatusCode)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func main() {
return
}
sch := scheduler.New(pge, logger)
apiserver.StatusReporter = sch
apiserver.Reporter = sch

for sch.Run(ctx) == scheduler.RunningStatus {
pge.ReconnectAndFixLeftovers(ctx)
Expand Down

0 comments on commit 952442b

Please sign in to comment.