Skip to content
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

【OpenApi】How to listen the config change based on the 2.x version nacos?【Implementing a v2.x nacos python sdk】 #12094

Closed
KunxiSun opened this issue May 14, 2024 · 4 comments

Comments

@KunxiSun
Copy link

KunxiSun commented May 14, 2024

Describe the bug

I am working on a nacos 2.x python sdk. Based on the OpenAPI V2.x document , I cannot find any records related to the config listener.

Only the following Apis are found
Get Setting
Create Setting
Delete Setting
Get the history setting list
Get a specific version setting
Get the last version setting
Get all setting of a namespace

Expected behavior
To support other language like python, can use nacos to register service, the v2 document should have api to listen the config change.

Actually behavior
I tried the v1 path, it can have response.
path: /nacos/v1/cs/configs/listener
response: data_id%02group_name%02name_space%01

How to Reproduce
Steps to reproduce the behavior:

  1. Go to nacos v2.x Open api
@Daydreamer-ia
Copy link
Contributor

The 2.x channel is implemented by grpc which is different from 1.x, not just simple http. May be you need to get some info about grpc and do some research for how to design grpc channel from other language nacos-sdk. By the way, the nacos-python-sdk supports 1.x config change listening supported by long polling.

import nacos
SERVER_ADDRESSES = "server addresses split by comma"
NAMESPACE = "namespace id"

client = nacos.NacosClient(SERVER_ADDRESSES, namespace=NAMESPACE)
data_id = "config.nacos"
group = "group"


def listen(args):
   print(args)


client.add_config_watcher(data_id, group, listen)

@KunxiSun
Copy link
Author

KunxiSun commented May 14, 2024

@Daydreamer-ia
Thanks for your response.

As you mentioned, nacos 2.x support grpc. I think it is a nice feature evovled from v1.x to v2.x, and I do know something about grpc(not too much).

As far as I know, the grpc requires a proto file to auto generate code for different language, where can I found the proto file of nacos?

@Daydreamer-ia
Copy link
Contributor

@Daydreamer-ia Thanks for your response.

As you mentioned, nacos 2.x support grpc. I think it is a nice feature evovled from v1.x to v2.x, and I do know something about grpc(not too much).

As far as I know, the grpc requires a proto file to auto generate code for different language, where can I found the proto file of nacos?

api/src/main/proto/nacos_grpc_service.proto

@KunxiSun
Copy link
Author

@Daydreamer-ia

By the way, does the method to send heartbeat in nacos 2.x changed? The OpenAPI V2.x document does not have any hints about how to send heartbeat.

However, I tried /nacos/v2/ns/instance/beat to send heartbeat, and it works, even though it is not mentioned in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants