From 3bbd76c678de239eb33e91f27769cdb788541c2e Mon Sep 17 00:00:00 2001 From: Vinayaka R Kamath Date: Mon, 12 Oct 2020 15:58:24 +0530 Subject: [PATCH 1/4] MB-41813: Implement browser search within a function Change-Id: I263742334ef46333dd4b9fdec7f10027952e37c0 Reviewed-on: http://review.couchbase.org/c/eventing/+/137942 Reviewed-by: Jeelan Basha Poola Tested-by: Vinayaka Kamath --- ui/eventing-ui/ui-current/eventing.js | 14 ++++++++++++++ .../ui-current/fragments/handler-editor.html | 1 + 2 files changed, 15 insertions(+) diff --git a/ui/eventing-ui/ui-current/eventing.js b/ui/eventing-ui/ui-current/eventing.js index 24c24bdd..2a0733e3 100644 --- a/ui/eventing-ui/ui-current/eventing.js +++ b/ui/eventing-ui/ui-current/eventing.js @@ -1261,6 +1261,12 @@ angular.module('eventing', [ console.log(err); }); + var config = require("ace/config"); + $scope.searchInCode = function() { + config.loadModule("ace/ext/cb-searchbox", + function(e) {if ($scope.editor) e.Search($scope.editor, true, true)}); + } + self.handler = app.appcode; self.pristineHandler = app.appcode; self.debugToolTip = "Displays a URL that connects the Chrome Dev-Tools with the application handler. Code must be deployed and debugger must be enabled in the settings in order to debug"; @@ -1279,6 +1285,14 @@ angular.module('eventing', [ // TODO : Figure out how to add N1QL grammar to ace editor. editor.getSession().setUseWorker(false); + $scope.editor = editor; + $scope.editor.commands.addCommand({ + name: "Search Pop Up.", + exec: $scope.searchInCode, + bindKey: {mac: "cmd-f", win: "ctrl-f"}, + readOnly: true + }); + // Allow editor to load fully and add annotations var showAnnotations = function() { // compilation errors diff --git a/ui/eventing-ui/ui-current/fragments/handler-editor.html b/ui/eventing-ui/ui-current/fragments/handler-editor.html index 09868122..fb7015c4 100644 --- a/ui/eventing-ui/ui-current/fragments/handler-editor.html +++ b/ui/eventing-ui/ui-current/fragments/handler-editor.html @@ -38,6 +38,7 @@ +
From 63eaf169e0332e15d2374f87bb5a8909b843043c Mon Sep 17 00:00:00 2001 From: AnkitPrabhu Date: Mon, 19 Oct 2020 22:23:14 +0530 Subject: [PATCH 2/4] MB-42125: Reject creation of function if source and metadata collection is same Change-Id: Icb19c0f018a42776061443f22972abd255cc464b Reviewed-on: http://review.couchbase.org/c/eventing/+/138435 Reviewed-by: Jeelan Basha Poola Tested-by: --- service_manager/http_handlers.go | 14 +++++++++++--- service_manager/status.go | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/service_manager/http_handlers.go b/service_manager/http_handlers.go index c6b651cd..9fe39dbf 100644 --- a/service_manager/http_handlers.go +++ b/service_manager/http_handlers.go @@ -1949,10 +1949,18 @@ func (m *ServiceMgr) savePrimaryStore(app *application) (info *runtimeInfo) { return } - if app.DeploymentConfig.SourceBucket == app.DeploymentConfig.MetadataBucket { + sourceKeyspace := common.Keyspace{BucketName: app.DeploymentConfig.SourceBucket, + ScopeName: app.DeploymentConfig.SourceScope, + CollectionName: app.DeploymentConfig.SourceCollection} + + metadataKeyspace := common.Keyspace{BucketName: app.DeploymentConfig.MetadataBucket, + ScopeName: app.DeploymentConfig.MetadataScope, + CollectionName: app.DeploymentConfig.MetadataCollection} + + if sourceKeyspace == metadataKeyspace { info.Code = m.statusCodes.errSrcMbSame.Code - info.Info = fmt.Sprintf("Function: %s source bucket same as metadata bucket. source_bucket : %s metadata_bucket : %s", - app.Name, app.DeploymentConfig.SourceBucket, app.DeploymentConfig.MetadataBucket) + info.Info = fmt.Sprintf("Function: %s source keyspace same as metadata keyspace. source : %s metadata : %s", + app.Name, sourceKeyspace, metadataKeyspace) logging.Errorf("%s %s", logPrefix, info.Info) return } diff --git a/service_manager/status.go b/service_manager/status.go index 6c995dd4..cf1990e5 100644 --- a/service_manager/status.go +++ b/service_manager/status.go @@ -330,7 +330,7 @@ func (m *ServiceMgr) initErrCodes() { { Name: m.statusCodes.errSrcMbSame.Name, Code: m.statusCodes.errSrcMbSame.Code, - Description: "Source bucket same as metadata bucket", + Description: "Source keyspace same as metadata keyspace", }, { Name: m.statusCodes.errInvalidExt.Name, From a993253587c754e5f91e60642b77e178563f87c8 Mon Sep 17 00:00:00 2001 From: Vinayaka R Kamath Date: Tue, 20 Oct 2020 14:59:13 +0530 Subject: [PATCH 3/4] MB-41798: Fill default timer_context_size when importing old handlers Change-Id: Ieab639834e075af7693ca4927ecf78ddf53ddb1c Reviewed-on: http://review.couchbase.org/c/eventing/+/138508 Reviewed-by: Tested-by: Vinayaka Kamath --- ui/eventing-ui/ui-current/eventing.js | 2 +- ui/eventing-ui/ui-current/fragments/app-settings.html | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/eventing-ui/ui-current/eventing.js b/ui/eventing-ui/ui-current/eventing.js index 2a0733e3..c53d03cb 100644 --- a/ui/eventing-ui/ui-current/eventing.js +++ b/ui/eventing-ui/ui-current/eventing.js @@ -2110,7 +2110,7 @@ angular.module('eventing', [ form.appname.$error.required = form.appname.$viewValue === '' || form.appname.$viewValue === undefined; - form.timer_context_size.$error.isnan = isNaN(form.timer_context_size.$error.isnum.$viewValue) + form.timer_context_size.$error.isnan = isNaN(form.timer_context_size.$viewValue) || (form.timer_context_size.$viewValue == null); return form.appname.$error.required || form.appname.$error.appExists || diff --git a/ui/eventing-ui/ui-current/fragments/app-settings.html b/ui/eventing-ui/ui-current/fragments/app-settings.html index 01888894..a22da7cf 100644 --- a/ui/eventing-ui/ui-current/fragments/app-settings.html +++ b/ui/eventing-ui/ui-current/fragments/app-settings.html @@ -295,6 +295,7 @@

Function Settings

type="number" name="timer_context_size" ng-model="appModel.settings.timer_context_size" + ng-init="appModel.settings.timer_context_size = appModel.settings.timer_context_size ? appModel.settings.timer_context_size : 1024" min="20" max="20971520">
Date: Mon, 19 Oct 2020 19:27:38 +0530 Subject: [PATCH 4/4] MB-40700: Update bucket function map after storing in primary store Change-Id: I0875c86ae407f375e8c3398489eee1b3e1d5d231 Reviewed-on: http://review.couchbase.org/c/eventing/+/138401 Tested-by: Reviewed-by: Jeelan Basha Poola --- service_manager/manager.go | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/service_manager/manager.go b/service_manager/manager.go index fc474e11..c426df9e 100644 --- a/service_manager/manager.go +++ b/service_manager/manager.go @@ -405,11 +405,27 @@ func (m *ServiceMgr) settingChangeCallback(path string, value []byte, rev interf return nil } - if value == nil { + m.fnMu.Lock() + defer m.fnMu.Unlock() + functionName := pathTokens[len(pathTokens)-1] + cfg, ok := m.fnsInPrimaryStore[functionName] + + if !ok { return nil } - functionName := pathTokens[len(pathTokens)-1] + if value == nil { + source := common.Keyspace{BucketName: cfg.SourceBucket, + ScopeName: cfg.SourceScope, + CollectionName: cfg.SourceCollection, + } + delete(m.bucketFunctionMap[source], functionName) + if len(m.bucketFunctionMap[source]) == 0 { + delete(m.bucketFunctionMap, source) + } + + return nil + } settings := make(map[string]interface{}) err := json.Unmarshal(value, &settings) @@ -433,11 +449,6 @@ func (m *ServiceMgr) settingChangeCallback(path string, value []byte, rev interf return nil } - m.fnMu.Lock() - defer m.fnMu.Unlock() - - cfg := m.fnsInPrimaryStore[functionName] - source, _ := m.getSourceAndDestinationsFromDepCfg(&cfg) if processingStatus == false { m.graph.removeEdges(functionName)