-
Notifications
You must be signed in to change notification settings - Fork 630
Broker, Trigger, and Namespace Controllers #788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
knative-prow-robot
merged 191 commits into
knative:master
from
Harwayne:broker-new-model
Mar 18, 2019
Merged
Changes from all commits
Commits
Show all changes
191 commits
Select commit
Hold shift + click to select a range
d7ed39b
Initial API outline for Broker.
Harwayne 080f5eb
Metadata is exported
Harwayne f20a2df
Initial Trigger API.
Harwayne 163474d
Remove old comments.
Harwayne 5f53e05
Register the types.
Harwayne 2f6a03f
Initial work on the Broker controller.
Harwayne 3ee0b8b
Initial work on the Trigger controller.
Harwayne da9fe36
Initial work on the new model and its corresponding broker controller.
Harwayne f8cca2e
Initial work on the Trigger controller.
Harwayne d7ebdcb
Add simple mains.
Harwayne c5f7a83
Small fixes, still not working.
Harwayne 054c10d
Add the Istio injection annotation.
Harwayne 942b979
Resolve subscriber in the Trigger controller.
Harwayne afd71af
Standardize on 'Any'.
Harwayne 7a1f69b
Make Broker and Trigger generational
Harwayne 2be56bd
Happy control path.
Harwayne 10acfa3
TargetPort is 8080
Harwayne 2108d83
Watch channels.
Harwayne 6aa7086
Custom service account for filter (needs trigger watch).
Harwayne 3cd236f
Increase logging in the Filter to debug level.
Harwayne be350a0
Use the default channel provisioner.
Harwayne 0068232
Adding filtering using k8s label selectors
nachocano b4e2358
Watch namespaces and create a default Broker.
Harwayne 3a9fd94
Merge remote-tracking branch 'broker/broker-new-model' into broker-ne…
nachocano 5ca1b9f
Updating trigger example with filters
nachocano bd53cda
Broker changes cause the namespace watcher to reconcile.
Harwayne 17889fb
Merge remote-tracking branch 'broker/broker-new-model' into broker-ne…
nachocano 582eb4c
Merge branch 'master' into broker-new-model
Harwayne 4f803a2
Move the Logging package import and format.
Harwayne eec0f8d
Updating after review comments. Only doing exact header matching.
nachocano ac3587e
Merge remote-tracking branch 'broker/broker-new-model' into broker-ne…
nachocano 34d42e0
Adding filtering expressions. Currently using LabelSelectors without
nachocano 1788a9b
Merge remote-tracking branch 'upstream/master' into broker-new
nachocano ad4e6f5
Changes to compile
nachocano bc519d8
moving filter
nachocano 3f47238
Moving cmds to broker
nachocano 3070157
updating controller
nachocano 0957fda
Moving provider and reconciler to reconciler folder, and merging them…
nachocano ea53702
Merge branch 'master' into broker-new-model
Harwayne f0106aa
Merge remote-tracking branch 'broker/broker-new-model' into broker-new
nachocano 509c8a1
Adding verbs to dispatcher
nachocano d33308b
Moving back mains to cmd
nachocano af83baa
Updating config
nachocano 8df699c
Moving resources to reconcilers
nachocano bd6a8fa
Moving broker folder back where it belongs
nachocano d2011e6
Merge pull request #5 from nachocano/broker-new
Harwayne d567412
Merge branch 'broker-new-model' into broker-new
nachocano 3b84c91
Revert "Merge branch 'broker-new-model' into broker-new"
nachocano 1d6c759
Merge remote-tracking branch 'broker/broker-new-model' into broker-new
nachocano 0e43a7f
Merge remote-tracking branch 'broker/broker-new-model' into filter-exp
nachocano 2df6bdc
Updating headers and headerExpressions to attributes and attributeExp…
nachocano bfe61c1
Merge branch 'master' into broker-clean-up
Harwayne 22efbe0
Reconcilers notice when mroe things change.
Harwayne 3a3c13c
PR comment.
Harwayne f834f89
Remove redundant watch.
Harwayne 698a40c
Merge pull request #6 from Harwayne/broker-clean-up
Harwayne 6b817ef
Unit test scaffold.
Harwayne 451b607
Merge pull request #7 from Harwayne/broker-unit-test-scaffold
Harwayne 4097d0a
Merge remote-tracking branch 'broker/broker-new-model' into broker-new
nachocano 97e642d
Tests for the namespace reconciler.
Harwayne 5e0319f
Merge pull request #8 from Harwayne/ns-test
Harwayne 4bb7fda
Merge remote-tracking branch 'broker/broker-new-model' into broker-new
nachocano da32bae
Exact matching for filters without using k8s selectors-based syntax.
nachocano 7bc8b7a
Merge remote-tracking branch 'broker/broker-new-model' into filter-exp
nachocano 8ccfcca
Removing t3 as we don't have set expressions
nachocano 29acf36
Updates after code review
nachocano e75141c
Attempt to reconcile broker in trigger controller
nachocano e79b8f7
Broker controller unit tests.
Harwayne ae665bd
Merge pull request #9 from Harwayne/broker-test
Harwayne af2f475
Merge remote-tracking branch 'broker/broker-new-model' into broker-new
nachocano dbe650a
Merge pull request #4 from nachocano/filter-exp
Harwayne 30f1c74
Deleting and re-creating subscription object as the backing channel
nachocano f363e02
Merge remote-tracking branch 'broker/broker-new-model' into broker-new
nachocano e45d19a
Adding comment
nachocano 1628333
Rename Trigger.Spec.Filter.ExactMatch to Trigger.Spec.Filter.SourceAn…
Harwayne a6d2650
Merge pull request #11 from Harwayne/filter-test
Harwayne 434bf9d
Merge remote-tracking branch 'broker/broker-new-model' into broker-new
nachocano cbbd066
Adding event messages
nachocano c33c569
Using the broker's namespacedNamed as key to the triggers map.
nachocano 66f6f44
Merge pull request #10 from nachocano/broker-new
Harwayne 40ca8da
Adding some tests to trigger
nachocano 650ef47
More UTs
nachocano d2c1ef8
More UTs
nachocano ae04007
More UTs
nachocano 6d6c488
Merge pull request #12 from nachocano/broker-new-trigger-ut
Harwayne 9c63dbc
Namespace reconciler automatically creates the Broker Filter's Servic…
Harwayne 3ad193f
Remove no longer needed label.
Harwayne d18acab
Broker and trigger types UTs
nachocano 2a02ba5
WIP early E2E test
grantr 54cdb3c
Changes after code review. Adding trigger defaults and validation tests
nachocano 11a1734
Cleaner trigger validation
nachocano d713eeb
Adding dummy tests for broker validation...
nachocano 89cdd58
Merge pull request #14 from nachocano/broker-new-trigger-ut
Harwayne bd4345a
Merge remote-tracking branch 'grantr/broker-new-model-e2e' into broke…
nachocano 49fd1a0
Compiling and moving things around
nachocano 4cdfd58
Updating test
nachocano b42d359
More updates
nachocano 29be515
Waiting for potentially multiple contents.
nachocano 1edbf0a
Compiling
nachocano 9c415e6
Fixing compilation
nachocano ac9b485
Fixing compilation errors. Adding AnnotateNamespace function.
nachocano 2b39168
Adding ns
nachocano ed9fcbe
Adding logs. Changing to lowercase any otherwise the pod name is invalid
nachocano 4848952
Removing namespace when creating trigger subscriber spec.
nachocano 311e174
Checking if all triggers are ready
nachocano d361afb
Updated logs
nachocano d1198a9
Working
nachocano 6bd659c
Adding logs... Still not receiving the events.
nachocano 0d80f9c
More logs
nachocano cd862ff
Adding build constraint
nachocano 2ea7aa3
Removing unnecessary stuff
nachocano aa60a8a
Removing ugly structs
nachocano 6471b4f
More logs
nachocano 6bc7f64
Merge pull request #13 from Harwayne/ns-rbac
Harwayne 56ad43c
Merge remote-tracking branch 'broker/broker-new-model' into broker-e2e
nachocano c4959e2
Removing quotes
nachocano 69ebf18
More logs
nachocano 1dccad8
Adding delay
nachocano 2b67eb8
Listing triggers in receiver when we create it, so that we don't miss
nachocano a44d6d2
Adding delay to sender pod
nachocano 41ab0a8
Removing withDelay method and just sleep for a while
nachocano 6a832ea
Improve log...
nachocano 446022a
Updates after code review.
nachocano 7f24f14
Adding some more logs and trailing dots.
nachocano 2a3eb19
Merge branch 'master' into broker-controller-runtime
Harwayne 9debaf2
Switch import order.
Harwayne abf3427
Merge pull request #16 from Harwayne/broker-controller-runtime
Harwayne a83ca82
Updating comments.
nachocano fda6550
Updating comments.
nachocano 3ee6343
Merge remote-tracking branch 'broker/broker-new-model' into broker-ge…
nachocano 2aae7eb
Replace the bad errgroup usage with the runnableServer.
Harwayne e15431d
Merge pull request #18 from Harwayne/codegen
Harwayne 5f201fa
Namespace scoped the Broker Filter's client.
Harwayne ba726b3
Fix unit tests.
Harwayne e7ff5b2
Fix yaml
Harwayne d640c7a
Merge pull request #19 from Harwayne/namespace-rolebinding
Harwayne dc91427
Merge remote-tracking branch 'broker/broker-new-model' into broker-e2e
nachocano 0ea0402
Merge branch 'broker-e2e' of github.com:nachocano/eventing into broke…
nachocano dcb8774
Setting source to source not type.
nachocano df88eab
Merge remote-tracking branch 'broker/broker-new-model' into broker-ge…
nachocano 86f7330
Merge pull request #15 from nachocano/broker-e2e
Harwayne b6fe6bd
Merge pull request #17 from nachocano/broker-gen-pass
Harwayne 71c5250
Switch from annotating the namespace to labeling it, to match Istio.
Harwayne b12da7e
Merge pull request #20 from Harwayne/ns-eventing-label
Harwayne 8d6df67
General clean up.
Harwayne c27d283
Merge pull request #21 from Harwayne/broker-cleanup
Harwayne d9a607c
Merge branch 'master' into broker-merge-master
Harwayne 77a69f9
Merge pull request #22 from Harwayne/broker-merge-master
Harwayne edcab3e
Initial docs for the Broker.
Harwayne 26586ab
Fill some of the usage section.
Harwayne a3e485f
Add instructions for installing the Broker without using Namespace an…
Harwayne 3e5f80e
Merge branch 'master' into broker-merge
Harwayne 4bdde4e
Merge pull request #29 from Harwayne/broker-merge
Harwayne 19f9653
Merge pull request #28 from Harwayne/broker-docs
Harwayne a367206
Create example_{brokers,triggers}.yaml to document how they can be used.
Harwayne 3447c4d
Merge pull request #30 from Harwayne/broker-cleanup
Harwayne a0599d6
Fix MD linter issues.
Harwayne a099404
Merge pull request #31 from Harwayne/md-fix
Harwayne 31f5e52
Fix MD linter issues.
Harwayne d0bd9dc
Merge pull request #32 from Harwayne/md-fix
Harwayne ac179cd
Fix MD linter issues.
Harwayne ac4e3f8
Merge pull request #33 from Harwayne/md-fix
Harwayne dfa159f
Minor clean up.
Harwayne 17ddb6c
Merge pull request #34 from Harwayne/broker-cleanup
Harwayne 8c779be
Merge branch 'master' into broker-merge
Harwayne 30f9031
Clean up some spots the merge didn't catch.
Harwayne c6a05c6
Merge pull request #35 from Harwayne/broker-merge
Harwayne ce0b024
Merge branch 'master' into broker-merge-2
Harwayne 0a34a1a
Merge branch 'master' into broker-new-model
Harwayne ac38587
Fix the bad merge by replacing logger.BaseLogger with logger.FormatLo…
Harwayne 923dc01
Merge pull request #37 from Harwayne/broker-merge-2
Harwayne 542d4a7
Add extra columns when using kubectl get.
Harwayne abf2495
MarkBrokerDoesNotExist
Harwayne bd5252d
Rename extra columns.
Harwayne 215fdd9
Merge pull request #38 from Harwayne/broker-pr-comments
Harwayne 5f9a5d4
Replace the Trigger reconciler's in-memory map with a simple list, ut…
Harwayne 6927fc6
Merge pull request #39 from Harwayne/trigger-list
Harwayne b9a7d0f
Accept v0.1 and v0.2 cloud events. Adding UTs.
nachocano 0a09e11
Merge branch 'master' into broker-fix-merge
Harwayne 7d8ee9e
Change to resolve.SubscriberSpec().
Harwayne 8691236
Merge remote-tracking branch 'broker/broker-new-model' into cloud_events
nachocano 99e7e45
Remove restClient as it wasn't actually used.
Harwayne 24e5285
Merge pull request #42 from Harwayne/remove-rest-config
Harwayne 24d7603
Only reconcile the Namespace if the specific resource we care about c…
Harwayne 7f7d554
Merge pull request #43 from Harwayne/namespace-resources
Harwayne c27bf22
lowercase
nachocano 0d169db
Merge pull request #40 from nachocano/cloud_events
Harwayne 37f0e4a
Mark the Broker's Ingress and Filter status condidionts failed when t…
Harwayne aef69fd
Merge pull request #45 from Harwayne/broker-mark-failed
Harwayne 6abe39c
Do not DeepCopy() in Reconcile(), as controller-runtime already did i…
Harwayne 0a60069
Merge pull request #46 from Harwayne/broker-no-deepcopy
Harwayne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 @@ | ||
| ../../../../.git/HEAD |
This file contains hidden or 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 @@ | ||
| ../../../../LICENSE |
This file contains hidden or 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 @@ | ||
| ../../../../third_party/VENDOR-LICENSE |
This file contains hidden or 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,85 @@ | ||
| /* | ||
| * Copyright 2019 The Knative Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "flag" | ||
| "log" | ||
| "os" | ||
|
|
||
| eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" | ||
| "github.com/knative/eventing/pkg/broker" | ||
| "github.com/knative/eventing/pkg/provisioners" | ||
| "github.com/knative/pkg/signals" | ||
| "go.uber.org/zap" | ||
| "go.uber.org/zap/zapcore" | ||
| "sigs.k8s.io/controller-runtime/pkg/client/config" | ||
| "sigs.k8s.io/controller-runtime/pkg/manager" | ||
| ) | ||
|
|
||
| const ( | ||
| NAMESPACE = "NAMESPACE" | ||
| ) | ||
|
|
||
| func main() { | ||
| logConfig := provisioners.NewLoggingConfig() | ||
| logConfig.LoggingLevel["provisioner"] = zapcore.DebugLevel | ||
| logger := provisioners.NewProvisionerLoggerFromConfig(logConfig).Desugar() | ||
| defer logger.Sync() | ||
|
|
||
| flag.Parse() | ||
|
|
||
| logger.Info("Starting...") | ||
|
|
||
| mgr, err := manager.New(config.GetConfigOrDie(), manager.Options{ | ||
| Namespace: getRequiredEnv(NAMESPACE), | ||
| }) | ||
| if err != nil { | ||
| logger.Fatal("Error starting up.", zap.Error(err)) | ||
| } | ||
|
|
||
| if err = eventingv1alpha1.AddToScheme(mgr.GetScheme()); err != nil { | ||
| logger.Fatal("Unable to add eventingv1alpha1 scheme", zap.Error(err)) | ||
| } | ||
|
|
||
| // We are running both the receiver (takes messages in from the Broker) and the dispatcher (send | ||
| // the messages to the triggers' subscribers) in this binary. | ||
| _, runnable := broker.New(logger, mgr.GetClient()) | ||
| err = mgr.Add(runnable) | ||
| if err != nil { | ||
| logger.Fatal("Unable to start the receivers runnable", zap.Error(err), zap.Any("runnable", runnable)) | ||
| } | ||
|
|
||
| // Set up signals so we handle the first shutdown signal gracefully. | ||
| stopCh := signals.SetupSignalHandler() | ||
|
|
||
| // Start blocks forever. | ||
| logger.Info("Manager starting...") | ||
| err = mgr.Start(stopCh) | ||
| if err != nil { | ||
| logger.Fatal("Manager.Start() returned an error", zap.Error(err)) | ||
| } | ||
| logger.Info("Exiting...") | ||
| } | ||
|
|
||
| func getRequiredEnv(envKey string) string { | ||
| val, defined := os.LookupEnv(envKey) | ||
| if !defined { | ||
| log.Fatalf("required environment variable not defined '%s'", envKey) | ||
| } | ||
| return val | ||
| } | ||
This file contains hidden or 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 @@ | ||
| ../../../../.git/HEAD |
This file contains hidden or 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 @@ | ||
| ../../../../LICENSE |
This file contains hidden or 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 @@ | ||
| ../../../../third_party/VENDOR-LICENSE |
This file contains hidden or 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,158 @@ | ||
| /* | ||
| * Copyright 2019 The Knative Authors | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "flag" | ||
| "fmt" | ||
| "log" | ||
| "net/http" | ||
| "os" | ||
| "time" | ||
|
|
||
| eventingv1alpha1 "github.com/knative/eventing/pkg/apis/eventing/v1alpha1" | ||
| "github.com/knative/eventing/pkg/provisioners" | ||
| "github.com/knative/pkg/signals" | ||
| "go.uber.org/zap" | ||
| "sigs.k8s.io/controller-runtime/pkg/client/config" | ||
| "sigs.k8s.io/controller-runtime/pkg/manager" | ||
| ) | ||
|
|
||
| var ( | ||
| port = 8080 | ||
|
|
||
| readTimeout = 1 * time.Minute | ||
| writeTimeout = 1 * time.Minute | ||
| ) | ||
|
|
||
| func main() { | ||
| logConfig := provisioners.NewLoggingConfig() | ||
| logger := provisioners.NewProvisionerLoggerFromConfig(logConfig).Desugar() | ||
| defer logger.Sync() | ||
| flag.Parse() | ||
|
|
||
| logger.Info("Starting...") | ||
|
|
||
| mgr, err := manager.New(config.GetConfigOrDie(), manager.Options{}) | ||
| if err != nil { | ||
| logger.Fatal("Error starting up.", zap.Error(err)) | ||
| } | ||
|
|
||
| if err = eventingv1alpha1.AddToScheme(mgr.GetScheme()); err != nil { | ||
| logger.Fatal("Unable to add eventingv1alpha1 scheme", zap.Error(err)) | ||
| } | ||
|
|
||
| c := getRequiredEnv("CHANNEL") | ||
|
|
||
| h := NewHandler(logger, c) | ||
|
|
||
| s := &http.Server{ | ||
| Addr: fmt.Sprintf(":%d", port), | ||
| Handler: h, | ||
| ErrorLog: zap.NewStdLog(logger), | ||
| ReadTimeout: readTimeout, | ||
| WriteTimeout: writeTimeout, | ||
| } | ||
|
|
||
| err = mgr.Add(&runnableServer{ | ||
| logger: logger, | ||
| s: s, | ||
| }) | ||
| if err != nil { | ||
| logger.Fatal("Unable to add runnableServer", zap.Error(err)) | ||
| } | ||
|
|
||
| // Set up signals so we handle the first shutdown signal gracefully. | ||
| stopCh := signals.SetupSignalHandler() | ||
| // Start blocks forever. | ||
| if err = mgr.Start(stopCh); err != nil { | ||
| logger.Error("manager.Start() returned an error", zap.Error(err)) | ||
| } | ||
| logger.Info("Exiting...") | ||
|
|
||
| ctx, cancel := context.WithTimeout(context.Background(), writeTimeout) | ||
| defer cancel() | ||
| if err = s.Shutdown(ctx); err != nil { | ||
| logger.Error("Shutdown returned an error", zap.Error(err)) | ||
| } | ||
| } | ||
|
|
||
| func getRequiredEnv(envKey string) string { | ||
| val, defined := os.LookupEnv(envKey) | ||
| if !defined { | ||
| log.Fatalf("required environment variable not defined '%s'", envKey) | ||
| } | ||
| return val | ||
| } | ||
|
|
||
| // http.Handler that takes a single request in and sends it out to a single destination. | ||
| type Handler struct { | ||
|
Harwayne marked this conversation as resolved.
|
||
| receiver *provisioners.MessageReceiver | ||
| dispatcher *provisioners.MessageDispatcher | ||
| destination string | ||
|
|
||
| logger *zap.Logger | ||
| } | ||
|
|
||
| // NewHandler creates a new ingress.Handler. | ||
| func NewHandler(logger *zap.Logger, destination string) *Handler { | ||
|
Harwayne marked this conversation as resolved.
|
||
| handler := &Handler{ | ||
| logger: logger, | ||
| dispatcher: provisioners.NewMessageDispatcher(logger.Sugar()), | ||
| destination: fmt.Sprintf("http://%s", destination), | ||
| } | ||
| // The receiver function needs to point back at the handler itself, so set it up after | ||
| // initialization. | ||
| handler.receiver = provisioners.NewMessageReceiver(createReceiverFunction(handler), logger.Sugar()) | ||
|
|
||
| return handler | ||
| } | ||
|
|
||
| func createReceiverFunction(f *Handler) func(provisioners.ChannelReference, *provisioners.Message) error { | ||
| return func(_ provisioners.ChannelReference, m *provisioners.Message) error { | ||
| // TODO Filter. | ||
|
Harwayne marked this conversation as resolved.
|
||
| return f.dispatch(m) | ||
| } | ||
| } | ||
|
|
||
| // http.Handler interface. | ||
| func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | ||
|
Harwayne marked this conversation as resolved.
|
||
| f.receiver.HandleRequest(w, r) | ||
| } | ||
|
|
||
| // dispatch takes the request, and sends it out the f.destination. If the dispatched | ||
| // request returns successfully, then return nil. Else, return an error. | ||
| func (f *Handler) dispatch(msg *provisioners.Message) error { | ||
| err := f.dispatcher.DispatchMessage(msg, f.destination, "", provisioners.DispatchDefaults{}) | ||
| if err != nil { | ||
| f.logger.Error("Error dispatching message", zap.String("destination", f.destination)) | ||
| } | ||
| return err | ||
| } | ||
|
|
||
| // runnableServer is a small wrapper around http.Server so that it matches the manager.Runnable | ||
| // interface. | ||
| type runnableServer struct { | ||
| logger *zap.Logger | ||
| s *http.Server | ||
| } | ||
|
|
||
| func (r *runnableServer) Start(<-chan struct{}) error { | ||
| r.logger.Info("Ingress Listening...", zap.String("Address", r.s.Addr)) | ||
| return r.s.ListenAndServe() | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.