-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
17 changed files
with
851 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,13 @@ | ||
apiPort: 8081 | ||
bindings: | ||
- name: kubemq-query-elastic-search | ||
source: | ||
kind: kubemq.query | ||
name: kubemq-query | ||
properties: | ||
address: "kubemq-cluster:50000" | ||
client_id: "kubemq-query-elastic-search-connector" | ||
auth_token: "" | ||
channel: "query.elastic" | ||
group: "" | ||
auto_reconnect: "true" | ||
reconnect_interval_seconds: "1" | ||
max_reconnects: "0" | ||
target: | ||
kind: stores.elasticsearch | ||
name: target-elasticsearch | ||
properties: | ||
urls: "http://localhost:9201" | ||
username: "" | ||
password: "" | ||
sniff: "false" | ||
- name: hazelcast | ||
source: | ||
kind: kubemq.query | ||
properties: | ||
log_level: "error" | ||
address: localhost:50000 | ||
channel: query.hazelcast | ||
target: | ||
kind: cache.hazelcast | ||
properties: | ||
address: localhost:5701 | ||
server name: test | ||
properties: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
bindings: | ||
- name: hazelcast | ||
source: | ||
kind: kubemq.query | ||
properties: | ||
address: localhost:50000 | ||
channel: query.hazelcast | ||
target: | ||
kind: cache.hazelcast | ||
properties: | ||
address: localhost:5701 | ||
server_name: test | ||
properties: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"github.com/kubemq-hub/kubemq-targets/types" | ||
"github.com/kubemq-io/kubemq-go" | ||
"github.com/nats-io/nuid" | ||
"log" | ||
"time" | ||
) | ||
|
||
func main() { | ||
client, err := kubemq.NewClient(context.Background(), | ||
kubemq.WithAddress("localhost", 50000), | ||
kubemq.WithClientId(nuid.Next()), | ||
kubemq.WithTransportType(kubemq.TransportTypeGRPC)) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
randomKey := nuid.Next() | ||
// set request | ||
setRequest := types.NewRequest(). | ||
SetMetadataKeyValue("method", "set"). | ||
SetMetadataKeyValue("map_name", "my_map"). | ||
SetMetadataKeyValue("key", randomKey). | ||
SetData([]byte("some-data")) | ||
querySetResponse, err := client.SetQuery(setRequest.ToQuery()). | ||
SetChannel("query.hazelcast"). | ||
SetTimeout(10 * time.Second).Send(context.Background()) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
setResponse, err := types.ParseResponse(querySetResponse.Body) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Println(fmt.Sprintf("set request for key: %s executed, response: %s", randomKey, setResponse.Metadata.String())) | ||
|
||
// get request | ||
getRequest := types.NewRequest(). | ||
SetMetadataKeyValue("method", "get"). | ||
SetMetadataKeyValue("map_name", "my_map"). | ||
SetMetadataKeyValue("key", randomKey) | ||
|
||
queryGetResponse, err := client.SetQuery(getRequest.ToQuery()). | ||
SetChannel("query.hazelcast"). | ||
SetTimeout(10 * time.Second).Send(context.Background()) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
getResponse, err := types.ParseResponse(queryGetResponse.Body) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Println(fmt.Sprintf("get request for key: %s executed, response: %s, data: %s", randomKey, getResponse.Metadata.String(), string(getResponse.Data))) | ||
|
||
// delete request | ||
|
||
delRequest := types.NewRequest(). | ||
SetMetadataKeyValue("method", "delete"). | ||
SetMetadataKeyValue("map_name", "my_map"). | ||
SetMetadataKeyValue("key", randomKey) | ||
|
||
queryDelResponse, err := client.SetQuery(delRequest.ToQuery()). | ||
SetChannel("query.hazelcast"). | ||
SetTimeout(10 * time.Second).Send(context.Background()) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
delResponse, err := types.ParseResponse(queryDelResponse.Body) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
log.Println(fmt.Sprintf("delete request for key: %s executed, response: %s", randomKey, delResponse.Metadata.String())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
565eb6ca495589f6e3aff99ce3995a1270b9792147a3dbac9e181493b4e6ceda | ||
c6a0ef67d4d192f0cd37c6755efe732d90cf2213d369a7af4cf87742673bd351 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# Kubemq hazelcast Target Connector | ||
|
||
Kubemq hazelcast target connector allows services using kubemq server to access hazelcast server functions such `set`, `get` and `delete`. | ||
|
||
## Prerequisites | ||
The following are required to run the hazelcast target connector: | ||
|
||
- kubemq cluster | ||
- hazelcast | ||
- kubemq-targets deployment | ||
|
||
## Configuration | ||
|
||
hazelcast target connector configuration properties: | ||
|
||
| Properties Key | Required| Description | Example | | ||
|:--------------------------|:--------|:-----------------------------|:-----------------| | ||
| address | yes | hazelcast connection string | "localhost:5701" | | ||
| username | no | hazelcast username | "admin" | | ||
| password | no | hazelcast password | "password" | | ||
| connectionAttemptLimit | no | hazelcast connection attempts(default 1) | 1 | | ||
| connectionAttemptPeriod | no | hazelcast attempt period seconds(default 5) | 5 | | ||
| connectionTimeout | no | hazelcast connection timeout seconds(default 5) | 5 | | ||
| ssl | no | hazelcast use ssl | false | | ||
| sslcertificatefile | no | hazelcast certificate file | "" | | ||
| sslcertificatekey | no | hazelcast certificate key | "" | | ||
| serverName | no | hazelcast server name | "myserver" | | ||
|
||
Example: | ||
|
||
```yaml | ||
bindings: | ||
- name: kubemq-hazelcast | ||
source: | ||
kind: kubemq.query | ||
properties: | ||
address: localhost:50000 | ||
channel: query.hazelcast | ||
target: | ||
kind: cache.hazelcast | ||
properties: | ||
address: localhost:5701 | ||
server_name: test | ||
properties: {} | ||
|
||
``` | ||
|
||
## Usage | ||
|
||
### Get Request | ||
|
||
Get request metadata setting: | ||
|
||
| Metadata Key | Required | Description | Possible values | | ||
|:-------------|:---------|:---------------------|:----------------| | ||
| key | yes | hazelcast key string | any string | | ||
| method | yes | get | "get" | | ||
| map_name | yes | hazelcast map name | "my_map" | | ||
|
||
|
||
Example: | ||
|
||
```json | ||
{ | ||
"metadata": { | ||
"key": "your-hazelcast-key", | ||
"map_name": "my_map", | ||
"method": "get" | ||
}, | ||
"data": null | ||
} | ||
``` | ||
|
||
### Set Request | ||
|
||
Set request metadata setting: | ||
|
||
| Metadata Key | Required | Description | Possible values | | ||
|:-------------|:---------|:-----------------|:----------------| | ||
| key | yes | hazelcast key | any string | | ||
| method | yes | set | "set" | | ||
| map_name | yes | hazelcast map name | "my_map" | | ||
|
||
Set request data setting: | ||
|
||
| Data Key | Required | Description | Possible values | | ||
|:---------|:---------|:----------------------------------|:--------------------| | ||
| data | yes | data to set for the hazelcast key | base64 bytes array | | ||
|
||
Example: | ||
|
||
```json | ||
{ | ||
"metadata": { | ||
"key": "your-hazelcast-key", | ||
"map_name": "my_map", | ||
"method": "set" | ||
}, | ||
"data": "c29tZS1kYXRh" | ||
} | ||
``` | ||
### Delete Request | ||
|
||
Delete request metadata setting: | ||
|
||
| Metadata Key | Required | Description | Possible values | | ||
|:-------------|:---------|:---------------------|:----------------| | ||
| key | yes | hazelcast key string | any string | | ||
| method | yes | delete | "delete" | | ||
| map_name | yes | hazelcast map name | "my_map" | | ||
|
||
|
||
Example: | ||
|
||
```json | ||
{ | ||
"metadata": { | ||
"key": "your-hazelcast-key", | ||
"map_name": "my_map", | ||
"method": "delete" | ||
}, | ||
"data": null | ||
} | ||
``` |
Oops, something went wrong.