little-cui closed pull request #296: Add development guide
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/296
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/docs/README.md b/docs/README.md
index df39a010..26c5894b 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,9 +1,11 @@
 ## Documentation Index
 
-#### [Api 
Documentation](https://rawcdn.githack.com/ServiceComb/service-center/master/docs/api-docs.html)
-
 #### [Design](/docs/design.md)
 
+#### [Development Guide](/docs/dev-guide.md) 
+
+- [Api 
Documentation](https://rawcdn.githack.com/ServiceComb/service-center/master/docs/api-docs.html)
+
 #### [Contribution Guide](/docs/contribution.md) 
 
 #### [Docker Image Guide](/docs/create-docker-image.md) 
diff --git a/docs/dev-guide.md b/docs/dev-guide.md
new file mode 100644
index 00000000..52127b65
--- /dev/null
+++ b/docs/dev-guide.md
@@ -0,0 +1,96 @@
+# Development Guide
+
+This chapter is about how to implement the feature of micro-service discovery 
with ServiceCenter,
+and you can get more detail at [here](/server/core/swagger/v3.yaml)
+
+## Micro-service registration
+```bash
+curl -X POST \
+  http://127.0.0.1:30100/registry/v3/microservices \
+  -H 'content-type: application/json' \
+  -H 'x-domain-name: default' \
+  -d '{
+       "service":
+       {
+               "appId": "default",
+               "serviceName": "DemoService",
+               "version":"1.0.0"
+       }
+}'
+```
+
+and then you can get the 'DemoService' ID like below:
+
+```json
+{
+    "serviceId": "a3fae679211211e8a831286ed488fc1b"
+}
+```
+
+## Instance registration
+
+mark down the micro-service ID and call the instance registration API:
+
+```bash
+curl -X POST \
+  
http://127.0.0.1:30100/registry/v3/microservices/a3fae679211211e8a831286ed488fc1b/instances
 \
+  -H 'content-type: application/json' \
+  -H 'x-domain-name: default' \
+  -d '{
+       "instance": 
+       {
+               "hostName":"demo-pc",
+           "endpoints": [
+                       "rest://127.0.0.1:8080"
+               ]
+       }
+}'
+```
+
+the successful response like below:
+
+```json
+{
+    "instanceId": "288ad703211311e8a831286ed488fc1b"
+}
+```
+
+if all are successful, it means you have completed the micro-service 
registration and instance publish
+
+## Discovery
+
+the next step is that discovery the micro-service instance by service name and 
version rule
+
+```bash
+curl -X GET \
+  
'http://127.0.0.1:30100/registry/v3/instances?appId=default&serviceName=DemoService&version=latest'
 \
+  -H 'content-type: application/json' \
+  -H 'x-consumerid: a3fae679211211e8a831286ed488fc1b' \
+  -H 'x-domain-name: default'
+```
+
+here, you can get the information from the response
+
+```json
+{
+    "instances": [
+        {
+            "instanceId": "b4c9e57f211311e8a831286ed488fc1b",
+            "serviceId": "a3fae679211211e8a831286ed488fc1b",
+            "version": "1.0.0",
+            "hostName": "demo-pc",
+            "endpoints": [
+                "rest://127.0.0.1:8080"
+            ],
+            "status": "UP",
+            "healthCheck": {
+                "mode": "push",
+                "interval": 30,
+                "times": 3
+            },
+            "timestamp": "1520322915",
+            "modTimestamp": "1520322915"
+        }
+    ]
+}
+```
\ No newline at end of file
diff --git a/server/infra/registry/registry.go 
b/server/infra/registry/registry.go
index b87aad18..575a351f 100644
--- a/server/infra/registry/registry.go
+++ b/server/infra/registry/registry.go
@@ -201,11 +201,11 @@ func (op PluginOp) FormatUrlParams() string {
        var buf bytes.Buffer
        buf.WriteString("action=")
        buf.WriteString(op.Action.String())
-       buf.WriteString("&mode=true")
+       buf.WriteString("&mode=")
        buf.WriteString(op.Mode.String())
        buf.WriteString("&key=")
        buf.Write(op.Key)
-       buf.WriteString(fmt.Sprintf("&value=%d", len(op.Value)))
+       buf.WriteString(fmt.Sprintf("&len=%d", len(op.Value)))
        if len(op.EndKey) > 0 {
                buf.WriteString("&end=")
                buf.Write(op.EndKey)


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to