-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c4a5e9
commit b87cb3a
Showing
107 changed files
with
11,359 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
injection "knative.dev/pkg/injection" | ||
"knative.dev/pkg/injection/sharedmain" | ||
"knative.dev/pkg/signals" | ||
|
||
"github.com/zeiss/typhoon/pkg/reconciler/redisbroker" | ||
"github.com/zeiss/typhoon/pkg/reconciler/trigger" | ||
) | ||
|
||
func main() { | ||
ctx := signals.NewContext() | ||
|
||
ns := os.Getenv("WORKING_NAMESPACE") | ||
if len(ns) != 0 { | ||
ctx = injection.WithNamespaceScope(ctx, ns) | ||
} | ||
|
||
sharedmain.MainWithContext(ctx, "core-controller", | ||
redisbroker.NewController, | ||
trigger.NewController, | ||
) | ||
} |
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,89 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"log" | ||
"os" | ||
|
||
"github.com/zeiss/typhoon/pkg/brokers/backend/impl/redis" | ||
"github.com/zeiss/typhoon/pkg/brokers/broker" | ||
|
||
"github.com/katallaxie/pkg/logger" | ||
"github.com/katallaxie/pkg/server" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// Config ... | ||
type Config struct { | ||
Flags *Flags | ||
} | ||
|
||
// Flags ... | ||
type Flags struct { | ||
Addr string | ||
} | ||
|
||
var cfg = &Config{ | ||
Flags: &Flags{}, | ||
} | ||
|
||
var rootCmd = &cobra.Command{ | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return run(cmd.Context()) | ||
}, | ||
} | ||
|
||
func init() { | ||
// rootCmd.PersistentFlags().StringVar(&cfg.Flags.Addr, "addr", ":3000", "addr") | ||
// rootCmd.PersistentFlags().StringVar(&cfg.Flags.DB.Database, "db-database", cfg.Flags.DB.Database, "Database name") | ||
// rootCmd.PersistentFlags().StringVar(&cfg.Flags.DB.Username, "db-username", cfg.Flags.DB.Username, "Database user") | ||
// rootCmd.PersistentFlags().StringVar(&cfg.Flags.DB.Password, "db-password", cfg.Flags.DB.Password, "Database password") | ||
// rootCmd.PersistentFlags().IntVar(&cfg.Flags.DB.Port, "db-port", cfg.Flags.DB.Port, "Database port") | ||
|
||
rootCmd.SilenceUsage = true | ||
} | ||
|
||
type srv struct{} | ||
|
||
func (b *srv) Start(ctx context.Context, _ server.ReadyFunc, _ server.RunFunc) func() error { | ||
return func() error { | ||
l, err := logger.NewLogSink() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
b := redis.New(nil, l.Sugar()) | ||
|
||
s, err := broker.NewInstance(nil, b) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return s.Start(ctx) | ||
} | ||
} | ||
|
||
func run(ctx context.Context) error { | ||
log.SetFlags(0) | ||
log.SetOutput(os.Stderr) | ||
|
||
logger.RedirectStdLog(logger.LogSink) | ||
|
||
broker := &srv{} | ||
|
||
srv, _ := server.WithContext(ctx) | ||
srv.Listen(broker, false) | ||
|
||
err := srv.Wait() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func main() { | ||
if err := rootCmd.Execute(); err != nil { | ||
panic(err) | ||
} | ||
} |
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,42 @@ | ||
package eventing | ||
|
||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
) | ||
|
||
const ( | ||
GroupName = "eventing.typhoon.zeiss.com" | ||
) | ||
|
||
// BrokersResource represents a Redis broker resource. | ||
var RedisBrokersResource = schema.GroupResource{ | ||
Group: GroupName, | ||
Resource: "redisbrokers", | ||
} | ||
|
||
// Given an object accessor, return a list of owner references that are brokers. | ||
func GetOwnerBrokers(object metav1.ObjectMetaAccessor) []metav1.OwnerReference { | ||
ors := []metav1.OwnerReference{} | ||
|
||
for _, or := range object.GetObjectMeta().GetOwnerReferences() { | ||
gv, err := schema.ParseGroupVersion(or.APIVersion) | ||
if err != nil { | ||
continue | ||
} | ||
|
||
if gv.Group == GroupName && IsBrokerKind(or.Kind) { | ||
ors = append(ors, or) | ||
} | ||
} | ||
|
||
return ors | ||
} | ||
|
||
func IsBrokerKind(kind string) bool { | ||
if kind == "RedisBroker" || kind == "MemoryBroker" { | ||
return true | ||
} | ||
|
||
return false | ||
} |
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,4 @@ | ||
// Package v1alpha1 is the v1alpha1 version of the API. | ||
// +k8s:deepcopy-gen=package | ||
// +groupName=eventing.typhoon.zeiss.com | ||
package v1alpha1 |
Oops, something went wrong.