You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@milagro.apache.org by sm...@apache.org on 2019/09/17 08:46:26 UTC

[incubator-milagro-dta] branch develop updated: Status rpc (#43)

This is an automated email from the ASF dual-hosted git repository.

smihaylov pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-milagro-dta.git


The following commit(s) were added to refs/heads/develop by this push:
     new ca212da  Status rpc (#43)
ca212da is described below

commit ca212dab2831a6fbcd448d0df8e7b80a33ec3937
Author: Howard Kitto <ki...@gmail.com>
AuthorDate: Tue Sep 17 03:46:22 2019 -0500

    Status rpc (#43)
    
    * client interface for status page
    
    * added status client with token header
    
    * status client endpoint
---
 pkg/api/client.go | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/pkg/api/client.go b/pkg/api/client.go
index 162afc2..c3510a3 100644
--- a/pkg/api/client.go
+++ b/pkg/api/client.go
@@ -36,6 +36,7 @@ var (
 type ClientService interface {
 	FulfillOrder(req *FulfillOrderRequest) (*FulfillOrderResponse, error)
 	FulfillOrderSecret(req *FulfillOrderSecretRequest) (*FulfillOrderSecretResponse, error)
+	Status(token string) (*StatusResponse, error)
 }
 
 // MilagroClientService - implements Service Interface
@@ -58,6 +59,11 @@ func ClientEndpoints() transport.HTTPEndpoints {
 			NewRequest:  func() interface{} { return &FulfillOrderSecretRequest{} },
 			NewResponse: func() interface{} { return &FulfillOrderSecretResponse{} },
 		},
+		"Status": {
+			Path:        "/" + apiVersion + "/status",
+			Method:      http.MethodGet,
+			NewResponse: func() interface{} { return &StatusResponse{} },
+		},
 	}
 }
 
@@ -93,3 +99,17 @@ func (c MilagroClientService) FulfillOrderSecret(req *FulfillOrderSecretRequest)
 	r := d.(*FulfillOrderSecretResponse)
 	return r, nil
 }
+
+//Status - Allows a client to see the status of the server that it is connecting too
+func (c MilagroClientService) Status(token string) (*StatusResponse, error) {
+	endpoint := c.endpoints["Status"]
+	ctx := context.Background()
+	ctx = transport.SetJWTAuthHeader(ctx, token)
+
+	s, err := endpoint(ctx, nil)
+	if err != nil {
+		return nil, err
+	}
+	r := s.(*StatusResponse)
+	return r, nil
+}