-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
monitor: replaced basic RPC with gRPC
- Loading branch information
1 parent
5ceabea
commit 0aea812
Showing
15 changed files
with
1,055 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"net/url" | ||
|
||
pb "github.com/mvisonneau/gitlab-ci-pipelines-exporter/pkg/monitor/protobuf" | ||
log "github.com/sirupsen/logrus" | ||
"google.golang.org/grpc" | ||
"google.golang.org/grpc/credentials/insecure" | ||
) | ||
|
||
// Client .. | ||
type Client struct { | ||
pb.MonitorClient | ||
} | ||
|
||
// NewClient .. | ||
func NewClient(ctx context.Context, endpoint *url.URL) *Client { | ||
log.WithField("endpoint", endpoint.String()).Debug("establishing gRPC connection to the server..") | ||
|
||
conn, err := grpc.DialContext( | ||
ctx, | ||
endpoint.String(), | ||
grpc.WithTransportCredentials(insecure.NewCredentials()), | ||
) | ||
if err != nil { | ||
log.WithField("endpoint", endpoint.String()).WithField("error", err).Fatal("could not connect to the server") | ||
} | ||
|
||
log.Debug("gRPC connection established") | ||
|
||
return &Client{ | ||
MonitorClient: pb.NewMonitorClient(conn), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package monitor | ||
|
||
import "time" | ||
|
||
type TaskSchedulingStatus struct { | ||
Last time.Time | ||
Next time.Time | ||
} |
Oops, something went wrong.