EventLog Microservice Client SDK for Node.js
This is a Node.js client SDK for pip-services-eventlog microservice.
It provides an easy to use abstraction over communication protocols:
- HTTP/REST client
- Direct client for monolythic deployments
- Null client to be used in testing
Quick Links:
Use
The easiest way to work with the microservice is to use client SDK.
The complete list of available client SDKs for different languages is listed in the Quick Links
If you use Golang then you should add dependency to the client SDK into go.mod file of your project
...
require (
github.com/pip-services-infrastructure/pip-services-eventlog-go v1.0.0
....
)
Inside your code get the reference to the client SDK
import (
clients1 "github.com/pip-services-infrastructure/pip-clients-eventlog-go/version1"
)
var client *clients1.EventLogHttpClientV1
Define client configuration parameters that match configuration of the microservice external API
// Client configuration
httpConfig := cconf.NewConfigParamsFromTuples(
"connection.protocol", "http",
"connection.port", "3000",
"connection.host", "localhost",
)
client = clients1.NewEventLogHttpClientV1()
client.Configure(httpConfig)
Instantiate the client and open connection to the microservice
// Connect to the microservice
err := client.Open("")
if (err) {
panic("Connection to the microservice failed");
}
defer client.Close("")
// Work with the microservice
Now the client is ready to perform operations
// Log system event
event1:=&clients1.SystemEventV1{
Type: "restart",
source: "server1",
Message: "Restarted server",
}
err := client.LogEvent(
"",
event1,
);
var now = time.Now();
// Get the list system events
page, err1 := client.getEvents(
"",
cdata.NewFilterParamsFromTuples(
"from_time": new Date(now.getTime() - 24 * 3600 * 1000),
"to_time": now,
"source": "server1"
), cdata.NewEmptyPagingParams(),
);
Acknowledgements
This client SDK was created and currently maintained by Sergey Seroukhov.