Re: [PR] Support none Node discovery and make it as default [skywalking-banyandb]
hanahmily merged PR #1003: URL: https://github.com/apache/skywalking-banyandb/pull/1003 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] Support none Node discovery and make it as default [skywalking-banyandb]
mrproliu commented on code in PR #1003:
URL:
https://github.com/apache/skywalking-banyandb/pull/1003#discussion_r2916434405
##
banyand/metadata/discovery/none/none.go:
##
@@ -0,0 +1,95 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 none implements a no-op node discovery for standalone mode.
+package none
+
+import (
+ "context"
+ "errors"
+
+ "github.com/apache/skywalking-banyandb/api/common"
+ databasev1
"github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1"
+ "github.com/apache/skywalking-banyandb/banyand/metadata/schema"
+)
+
+var _ schema.NodeDiscovery = (*noneDiscovery)(nil)
+
+var errNotSupported = errors.New("none discovery does not support node
registration or update")
+
+type noneDiscovery struct {
+ curNode *databasev1.Node
+}
+
+// NewService creates a new none discovery service for standalone mode.
+// It extracts the current node information from the context.
+func NewService(ctx context.Context) schema.NodeDiscovery {
+ n := &noneDiscovery{}
+ if val := ctx.Value(common.ContextNodeKey); val != nil {
+ node := val.(common.Node)
+ var nodeRoles []databasev1.Role
+ if rolesVal := ctx.Value(common.ContextNodeRolesKey); rolesVal
!= nil {
+ nodeRoles = rolesVal.([]databasev1.Role)
+ }
+ n.curNode = node.ToProtoNode(nodeRoles)
+ }
+ return n
+}
Review Comment:
Added a test about it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] Support none Node discovery and make it as default [skywalking-banyandb]
mrproliu commented on code in PR #1003:
URL:
https://github.com/apache/skywalking-banyandb/pull/1003#discussion_r2916432463
##
banyand/metadata/discovery/none/none.go:
##
@@ -0,0 +1,95 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 none implements a no-op node discovery for standalone mode.
+package none
+
+import (
+ "context"
+ "errors"
+
+ "github.com/apache/skywalking-banyandb/api/common"
+ databasev1
"github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1"
+ "github.com/apache/skywalking-banyandb/banyand/metadata/schema"
+)
+
+var _ schema.NodeDiscovery = (*noneDiscovery)(nil)
+
+var errNotSupported = errors.New("none discovery does not support node
registration or update")
+
+type noneDiscovery struct {
+ curNode *databasev1.Node
+}
+
+// NewService creates a new none discovery service for standalone mode.
+// It extracts the current node information from the context.
+func NewService(ctx context.Context) schema.NodeDiscovery {
+ n := &noneDiscovery{}
+ if val := ctx.Value(common.ContextNodeKey); val != nil {
+ node := val.(common.Node)
+ var nodeRoles []databasev1.Role
+ if rolesVal := ctx.Value(common.ContextNodeRolesKey); rolesVal
!= nil {
+ nodeRoles = rolesVal.([]databasev1.Role)
+ }
+ n.curNode = node.ToProtoNode(nodeRoles)
+ }
+ return n
+}
+
+// ListNode returns the current node if it matches the given role.
+func (n *noneDiscovery) ListNode(_ context.Context, role databasev1.Role)
([]*databasev1.Node, error) {
+ if n.curNode == nil {
+ return nil, nil
+ }
+ for _, r := range n.curNode.GetRoles() {
+ if r == role {
+ return []*databasev1.Node{n.curNode}, nil
+ }
+ }
+ return nil, nil
Review Comment:
Added the `ROLE_UNSPECIFIED` check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Re: [PR] Support none Node discovery and make it as default [skywalking-banyandb]
codecov-commenter commented on PR #1003: URL: https://github.com/apache/skywalking-banyandb/pull/1003#issuecomment-4036935155 ## [Codecov](https://app.codecov.io/gh/apache/skywalking-banyandb/pull/1003?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report :white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 30.09%. Comparing base ([`3530dd9`](https://app.codecov.io/gh/apache/skywalking-banyandb/commit/3530dd9b5cefaa4fef60eec91ecbfbdfcaf243c5?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`efc20ce`](https://app.codecov.io/gh/apache/skywalking-banyandb/commit/efc20cebcef5e3e3c95815be59d199bfead89dd7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)). :warning: Report is 150 commits behind head on main. > :exclamation: There is a different number of reports uploaded between BASE (3530dd9) and HEAD (efc20ce). Click for more details. > > HEAD has 1 upload less than BASE > >| Flag | BASE (3530dd9) | HEAD (efc20ce) | >|--|--|--| >||1|0| > Additional details and impacted files ```diff @@ Coverage Diff @@ ## main#1003 +/- ## === - Coverage 45.97% 30.09% -15.89% === Files 328 123 -205 Lines 5550512850-42655 === - Hits25520 3867-21653 + Misses 27909 8612-19297 + Partials 2076 371 -1705 ``` | [Flag](https://app.codecov.io/gh/apache/skywalking-banyandb/pull/1003/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | |---|---|---| | [pkg](https://app.codecov.io/gh/apache/skywalking-banyandb/pull/1003/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `30.09% <ø> (?)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more. [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/skywalking-banyandb/pull/1003?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache). :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache). :rocket: New features to boost your workflow: - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems. - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [PR] Support none Node discovery and make it as default [skywalking-banyandb]
Copilot commented on code in PR #1003:
URL:
https://github.com/apache/skywalking-banyandb/pull/1003#discussion_r2916251031
##
CHANGES.md:
##
@@ -26,6 +26,7 @@ Release Notes.
- Support map-reduce aggregation for measure queries: map phase (partial
aggregation on data nodes) and reduce phase (final aggregation on liaison).
- Add eBPF-based KTM I/O monitor for FODC agent.
- Support relative paths in configuration.
+- Support none Node discovery and make it as default.
Review Comment:
CHANGES entry reads a bit awkwardly and has inconsistent capitalization.
Consider rephrasing to something like “Support 'none' node discovery and make
it the default.”
```suggestion
- Support 'none' node discovery and make it the default.
```
##
banyand/metadata/discovery/none/none.go:
##
@@ -0,0 +1,95 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 none implements a no-op node discovery for standalone mode.
+package none
+
+import (
+ "context"
+ "errors"
+
+ "github.com/apache/skywalking-banyandb/api/common"
+ databasev1
"github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1"
+ "github.com/apache/skywalking-banyandb/banyand/metadata/schema"
+)
+
+var _ schema.NodeDiscovery = (*noneDiscovery)(nil)
+
+var errNotSupported = errors.New("none discovery does not support node
registration or update")
+
+type noneDiscovery struct {
+ curNode *databasev1.Node
+}
+
+// NewService creates a new none discovery service for standalone mode.
+// It extracts the current node information from the context.
+func NewService(ctx context.Context) schema.NodeDiscovery {
+ n := &noneDiscovery{}
+ if val := ctx.Value(common.ContextNodeKey); val != nil {
+ node := val.(common.Node)
+ var nodeRoles []databasev1.Role
+ if rolesVal := ctx.Value(common.ContextNodeRolesKey); rolesVal
!= nil {
+ nodeRoles = rolesVal.([]databasev1.Role)
+ }
+ n.curNode = node.ToProtoNode(nodeRoles)
+ }
+ return n
+}
+
+// ListNode returns the current node if it matches the given role.
+func (n *noneDiscovery) ListNode(_ context.Context, role databasev1.Role)
([]*databasev1.Node, error) {
+ if n.curNode == nil {
+ return nil, nil
+ }
+ for _, r := range n.curNode.GetRoles() {
+ if r == role {
+ return []*databasev1.Node{n.curNode}, nil
+ }
+ }
+ return nil, nil
Review Comment:
`ListNode` currently returns an empty list when `role` is
`ROLE_UNSPECIFIED`. In the other discovery implementations (DNS/file),
`ROLE_UNSPECIFIED` is treated as “list all nodes”, so callers using that
convention would see no nodes in `none` mode. Consider returning the current
node when `role` is `ROLE_UNSPECIFIED` (and still filtering when a specific
role is provided).
##
banyand/metadata/discovery/none/none.go:
##
@@ -0,0 +1,95 @@
+// Licensed to Apache Software Foundation (ASF) under one or more contributor
+// license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright
+// ownership. Apache Software Foundation (ASF) licenses this file to you 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 none implements a no-op node discovery for standalone mode.
+package none
+
+import (
+ "context"
+ "errors"
+
+ "github.com/apache/skywalking-banyandb/api/common"
+ databasev1
"github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1"
+ "github.com/apache/skywal
[PR] Support none Node discovery and make it as default [skywalking-banyandb]
mrproliu opened a new pull request, #1003: URL: https://github.com/apache/skywalking-banyandb/pull/1003 - [ ] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Fixes apache/skywalking#. - [x] Update the [`CHANGES` log](https://github.com/apache/skywalking-banyandb/blob/main/CHANGES.md). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
