Skip to content

Commit

Permalink
Add part of docs
Browse files Browse the repository at this point in the history
  • Loading branch information
levichevdmitry committed Feb 28, 2020
1 parent 67e741e commit 306da27
Show file tree
Hide file tree
Showing 20 changed files with 674 additions and 629 deletions.
25 changes: 25 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# <img src="https://github.com/pip-services/pip-services/raw/master/design/Logo.png" alt="Pip.Services Logo" style="max-width:30%"> <br/> Remote Procedure Calls for Node.js

This framework is a part of the [Pip.Services](https://github.com/pip-services/pip-services) project.
It provides the following synchronous communication components:

- [**Direct**](https://pip-services3-node.github.io/pip-services3-rpc-node/classes/clients.directclient.html) - Direct client
- **Rest** - RESTful [services](https://pip-services3-node.github.io/pip-services3-rpc-node/classes/services.restservice.html) and [clients](https://pip-services3-node.github.io/pip-services3-rpc-node/classes/clients.restclient.html)
- **Status** - [Heartbeat](https://pip-services3-node.github.io/pip-services3-rpc-node/classes/services.heartbeatrestservice.html) and [status](https://pip-services3-node.github.io/pip-services3-rpc-node/classes/services.statusrestservice.html) services

Quick Links:

* [Downloads](https://github.com/pip-services3-node/pip-services3-rpc-node/blob/master/docs/Downloads.md)
* [API Reference](https://pip-services3-node.github.io/pip-services3-rpc-node/globals.html)
* [Building and Testing](https://github.com/pip-services3-node/pip-services3-rpc-node/blob/master/docs/Development.md)
* [Contributing](https://github.com/pip-services3-node/pip-services3-rpc-node/blob/master/docs/Development.md#contrib)

## Acknowledgements

The Node.js version of Pip.Services is created and maintained by:
- **Volodymyr Tkachenko**
- **Sergey Seroukhov**
- **Mark Zontak**

The documentation is written by:
- **Mark Makarychev**
6 changes: 0 additions & 6 deletions auth/RoleAuthorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import (
services "github.com/pip-services3-go/pip-services3-rpc-go/services"
)

// /** @module auth */
// const _ = require("lodash");

// import { UnauthorizedException } from "pip-services3-commons-node";
// import { HttpResponseSender } from "../services/HttpResponseSender";

type RoleAuthorizer struct {
}

Expand Down
36 changes: 16 additions & 20 deletions build/DefaultRpcFactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import (
"github.com/pip-services3-go/pip-services3-rpc-go/services"
)

/*
Creates RPC components by their descriptors.
// DefaultRpcFactory are creates RPC components by their descriptors.

See [[https://rawgit.com/pip-services-node/pip-services3-components-node/master/doc/api/classes/build.factory.html Factory]]
See [[HttpEndpoint]]
See [[HeartbeatRestService]]
See [[StatusRestService]]
*/
// See Factory
// See HttpEndpoint
// See HeartbeatRestService
// See StatusRestService
type DefaultRpcFactory struct {
cbuild.Factory
Descriptor *cref.Descriptor
Expand All @@ -22,19 +20,17 @@ type DefaultRpcFactory struct {
HeartbeatServiceDescriptor *cref.Descriptor
}

/*
Create a new instance of the factory.
*/
// NewDefaultRpcFactorymethod create a new instance of the factory.
func NewDefaultRpcFactory() *DefaultRpcFactory {
drf := DefaultRpcFactory{}
drf.Factory = *cbuild.NewFactory()
drf.Descriptor = cref.NewDescriptor("pip-services", "factory", "rpc", "default", "1.0")
drf.HttpEndpointDescriptor = cref.NewDescriptor("pip-services", "endpoint", "http", "*", "1.0")
drf.StatusServiceDescriptor = cref.NewDescriptor("pip-services", "status-service", "http", "*", "1.0")
drf.HeartbeatServiceDescriptor = cref.NewDescriptor("pip-services", "heartbeat-service", "http", "*", "1.0")
c := DefaultRpcFactory{}
c.Factory = *cbuild.NewFactory()
c.Descriptor = cref.NewDescriptor("pip-services", "factory", "rpc", "default", "1.0")
c.HttpEndpointDescriptor = cref.NewDescriptor("pip-services", "endpoint", "http", "*", "1.0")
c.StatusServiceDescriptor = cref.NewDescriptor("pip-services", "status-service", "http", "*", "1.0")
c.HeartbeatServiceDescriptor = cref.NewDescriptor("pip-services", "heartbeat-service", "http", "*", "1.0")

drf.RegisterType(drf.HttpEndpointDescriptor, services.NewHttpEndpoint)
drf.RegisterType(drf.HeartbeatServiceDescriptor, services.NewHeartbeatRestService)
drf.RegisterType(drf.StatusServiceDescriptor, services.NewStatusRestService)
return &drf
c.RegisterType(c.HttpEndpointDescriptor, services.NewHttpEndpoint)
c.RegisterType(c.HeartbeatServiceDescriptor, services.NewHeartbeatRestService)
c.RegisterType(c.StatusServiceDescriptor, services.NewStatusRestService)
return &c
}
68 changes: 37 additions & 31 deletions clients/CommandableHttpClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import (
cdata "github.com/pip-services3-go/pip-services3-commons-go/data"
)

/* CommandableHttpClient is abstract client that calls commandable HTTP service.
/*
CommandableHttpClient is abstract client that calls commandable HTTP service.
Commandable services are generated automatically for ICommandable objects.
Each command is exposed as POST operation that receives all parameters
in body object.
Configuration parameters
Configuration parameters:
base_route: base route for remote URI
- connection(s):
- discovery_key: (optional) a key to retrieve the connection from connect.idiscovery.html IDiscovery]]
- protocol: connection protocol: http or https
Expand All @@ -35,57 +35,63 @@ References:
Example:
class MyCommandableHttpClient extends CommandableHttpClient implements IMyClient {
type MyCommandableHttpClient struct{
*CommandableHttpClient
prototype reflect.Type // type of operation data
...
}
result, err := func (c * MyCommandableHttpClient) GetData(correlationId string, id string)(result MyData, err error){
func (c * CommandableHttpClient) getData(correlationId: string, id: string,
callback: (err: any, result: MyData) => void): void {
c.callCommand(
params:= cdata.NewEmptyStringValueMap()
params.Set("id",id)
res, err := c.CallCommand(
prototype
"get_data",
correlationId,
{ id: id },
(err, result) => {
callback(err, result);
}
);
params)
...
// convert response to MyData
...
return result, err
}
...
}
let client = new MyCommandableHttpClient();
client.configure(ConfigParams.fromTuples(
client = NewMyCommandableHttpClient();
client.Configure(cconf.NewConfigParamsFromTuples(
"connection.protocol", "http",
"connection.host", "localhost",
"connection.port", 8080
));
client.getData("123", "1", (err, result) => {
result, err := client.GetData("123", "1")
...
});
*/
type CommandableHttpClient struct {
RestClient
}

// NewCommandableHttpClientr is creates a new instance of the client.
// - baseRoute a base route for remote service.
// NewCommandableHttpClient is creates a new instance of the client.
// Parameters:
// - baseRoute string a base route for remote service.
// Returns: *CommandableHttpClient
// pointer on new instance
func NewCommandableHttpClient(baseRoute string) *CommandableHttpClient {
chc := CommandableHttpClient{}
chc.RestClient = *NewRestClient()
chc.BaseRoute = baseRoute
return &chc
c := CommandableHttpClient{}
c.RestClient = *NewRestClient()
c.BaseRoute = baseRoute
return &c
}

// CallCommand is calls a remote method via HTTP commadable protocol.
// The call is made via POST operation and all parameters are sent in body object.
// The complete route to remote method is defined as baseRoute + "/" + name.
//
// - name a name of the command to call.
// - correlationId (optional) transaction id to trace execution through call chain.
// - params command parameters.
// - callback callback function that receives result or error.

// Parameters:
// - prototype reflect.Type type of returned data
// - name string a name of the command to call.
// - correlationId string (optional) transaction id to trace execution through call chain.
// - params cdata.StringValueMap command parameters.
// Returns: result interface{}, err error
// result or error.
func (c *CommandableHttpClient) CallCommand(prototype reflect.Type, name string, correlationId string, params *cdata.StringValueMap,
data interface{}) (result interface{}, err error) {
timing := c.Instrument(correlationId, c.BaseRoute+"."+name)
Expand Down
5 changes: 5 additions & 0 deletions clients/Convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"reflect"
)

//ConvertComandResult method helps get correct result from JSON by prototype
//Parameters:
// - comRes interface{} input JSON string
// - prototype reflect.Type output object prototype
// Returns: convRes interface{}, err error
func ConvertComandResult(comRes interface{}, prototype reflect.Type) (convRes interface{}, err error) {

str, ok := comRes.([]byte)
Expand Down
Loading

0 comments on commit 306da27

Please sign in to comment.