Skip to content

Commit

Permalink
Merge d3d629f into fcebcc4
Browse files Browse the repository at this point in the history
  • Loading branch information
harture committed Nov 14, 2018
2 parents fcebcc4 + d3d629f commit 6a99dd1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
30 changes: 16 additions & 14 deletions cmd/keycloakb/keycloak_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func main() {
keycloakEnabled = c.GetBool("keycloak")
redisEnabled = c.GetBool("redis")
sentryEnabled = c.GetBool("sentry")
jobEnabled = c.GetBool("job")
pprofRouteEnabled = c.GetBool("pprof-route-enabled")

// Influx
Expand Down Expand Up @@ -231,8 +232,8 @@ func main() {
}

// Flaki.
var flakiClient fb_flaki.FlakiClient
{
var flakiClient fb_flaki.FlakiClient = &keycloakb.NoopFlakiClient{}
if flakiEnabled {
// Set up a connection to the flaki-service.
var conn *grpc.ClientConn
{
Expand All @@ -246,20 +247,20 @@ func main() {
}

flakiClient = fb_flaki.NewFlakiClient(conn)
}

// Get unique ID for this component
{
var b = flatbuffers.NewBuilder(0)
fb_flaki.FlakiRequestStart(b)
b.Finish(fb_flaki.FlakiRequestEnd(b))
// Get unique ID for this component
{
var b = flatbuffers.NewBuilder(0)
fb_flaki.FlakiRequestStart(b)
b.Finish(fb_flaki.FlakiRequestEnd(b))

var res, err = flakiClient.NextValidID(context.Background(), b)
if err != nil {
logger.Log("msg", "could not connect to flaki-service", "error", err)
return
var res, err = flakiClient.NextValidID(context.Background(), b)
if err != nil {
logger.Log("msg", "could not connect to flaki-service", "error", err)
return
}
ComponentID = string(res.Id())
}
ComponentID = string(res.Id())
}

// Add component name, component ID and version to the logger tags.
Expand Down Expand Up @@ -581,7 +582,7 @@ func main() {
}

// Jobs
{
if jobEnabled {
var ctrl = controller.NewController(ComponentName, ComponentID, idgenerator.New(flakiClient, tracer), &job_lock.NoopLocker{}, controller.EnableStatusStorage(job_status.New(cockroachConn)))

for _, job := range []string{"cockroach", "elasticsearch", "flaki", "influx", "jaeger", "keycloak", "redis", "sentry"} {
Expand Down Expand Up @@ -842,6 +843,7 @@ func config(logger log.Logger) *viper.Viper {
v.SetDefault("cockroach-clean-interval", "24h")

// Jobs
v.SetDefault("job", false)
v.SetDefault("job-flaki-health-validity", "1m")
v.SetDefault("job-influx-health-validity", "1m")
v.SetDefault("job-jaeger-health-validity", "1m")
Expand Down
1 change: 1 addition & 0 deletions configs/keycloak_bridge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jaeger-collector-healthcheck-host-port:
pprof-route-enabled: true

# Jobs
job: false
job-es-health-validity: 1m
job-flaki-health-validity: 1m
job-influx-health-validity: 1m
Expand Down
23 changes: 23 additions & 0 deletions internal/keycloakb/flaki.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package keycloakb

import (
errors "github.com/pkg/errors"
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"

fb "github.com/cloudtrust/keycloak-bridge/api/flaki/fb"
flatbuffers "github.com/google/flatbuffers/go"
)

// NoopCockroach is a cockroach client that does nothing.
type NoopFlakiClient struct{}

func (c NoopFlakiClient) NextID(ctx context.Context, in *flatbuffers.Builder,
opts ...grpc.CallOption) (*fb.FlakiReply, error) {
return nil, errors.New("Flaki is disabled")
}

func (c NoopFlakiClient) NextValidID(ctx context.Context, in *flatbuffers.Builder,
opts ...grpc.CallOption) (*fb.FlakiReply, error) {
return nil, errors.New("Flaki is disabled")
}

0 comments on commit 6a99dd1

Please sign in to comment.