@@ -33,6 +33,7 @@ type APIInterface interface {
3333 OpenPort (ctx context.Context , port * gitpod.WorkspaceInstancePort ) (res * gitpod.WorkspaceInstancePort , err error )
3434 UpdateGitStatus (ctx context.Context , status * gitpod.WorkspaceInstanceRepoStatus ) (err error )
3535 WorkspaceUpdates (ctx context.Context ) (<- chan * gitpod.WorkspaceInstance , error )
36+ SendHeartbeat (ctx context.Context ) (err error )
3637
3738 // Metrics
3839 RegisterMetrics (registry * prometheus.Registry ) error
@@ -69,6 +70,29 @@ type Service struct {
6970 apiMetrics * ClientMetrics
7071}
7172
73+ // SendHeartbeat implements APIInterface.
74+ func (s * Service ) SendHeartbeat (ctx context.Context ) (err error ) {
75+ if s == nil {
76+ return errNotConnected
77+ }
78+ startTime := time .Now ()
79+ defer func () {
80+ s .apiMetrics .ProcessMetrics ("SendHeartbeat" , err , startTime )
81+ }()
82+
83+ workspaceID := s .cfg .WorkspaceID
84+ service := v1 .NewIDEClientServiceClient (s .publicAPIConn )
85+
86+ payload := & v1.SendHeartbeatRequest {
87+ WorkspaceId : workspaceID ,
88+ }
89+ _ , err = service .SendHeartbeat (ctx , payload )
90+ if err != nil {
91+ log .WithField ("method" , "SendHeartbeat" ).WithError (err ).Error ("failed to call PublicAPI" )
92+ }
93+ return err
94+ }
95+
7296var _ APIInterface = (* Service )(nil )
7397
7498func NewServerApiService (ctx context.Context , cfg * ServiceConfig , tknsrv api.TokenServiceServer ) * Service {
@@ -80,6 +104,7 @@ func NewServerApiService(ctx context.Context, cfg *ServiceConfig, tknsrv api.Tok
80104 "function:openPort" ,
81105 "function:trackEvent" ,
82106 "function:getWorkspace" ,
107+ "function:sendHeartBeat" ,
83108 },
84109 })
85110 if err != nil {
0 commit comments