Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Merge branch 'devel' into task/ebruck/KEP-1362
Browse files Browse the repository at this point in the history
  • Loading branch information
ebruck committed Apr 29, 2019
2 parents afe7993 + 35fcf0a commit 4422298
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
21 changes: 12 additions & 9 deletions README.md
Expand Up @@ -267,10 +267,11 @@ Follow instructions in readme.md
#### Connectivity Test

```text
$ ./crud -p -n localhost:50000 status
$ ./crud -s <SWARM-ID> -n localhost:49154 status
Client: crud-script-0
Sending:
Sending:
swarm_id: "<SWARM-ID>"
sender: "crud-script-0"
status_request: ""
Expand Down Expand Up @@ -346,7 +347,7 @@ Response:
#### Create database
```text
./crud -p -n localhost:50000 create-db -u myuuid
./crud -s <SWARM-ID> -n localhost:50000 create-db -u myuuid
Client: crud-script-0
------------------------------------------------------------
Expand All @@ -363,7 +364,7 @@ header {
#### Create

```text
$ ./crud -p -n localhost:50000 create -u myuuid -k mykey -v myvalue
$ ./crud -s <SWARM-ID> -n localhost:50000 create -u myuuid -k mykey -v myvalue
Client: crud-script-0
------------------------------------------------------------
Expand All @@ -380,7 +381,7 @@ header {
#### Read

```text
$ ./crud -p -n localhost:50000 read -u myuuid -k mykey
$ ./crud -s <SWARM-ID> -n localhost:50000 read -u myuuid -k mykey
Client: crud-script-0
------------------------------------------------------------
Expand All @@ -401,7 +402,7 @@ read {
#### Update

```text
$ ./crud -p -n localhost:50000 update -u myuuid -k mykey -v mynewvalue
$ ./crud -s <SWARM-ID> -n localhost:50000 update -u myuuid -k mykey -v mynewvalue
Client: crud-script-0
------------------------------------------------------------
Expand All @@ -418,7 +419,7 @@ header {
#### Delete

```text
$ ./crud -p -n localhost:50000 delete -u myuuid -k mykey
$ ./crud -s <SWARM-ID> -n localhost:50000 delete -u myuuid -k mykey
Client: crud-script-0
------------------------------------------------------------
Expand All @@ -435,7 +436,7 @@ header {
#### Subscribe

```text
$ ./crud -p -n localhost:50000 subscribe -u myuuid -k mykey
$ ./crud -s <SWARM-ID> -n localhost:50000 subscribe -u myuuid -k mykey
Client: crud-script-0
------------------------------------------------------------
Expand Down Expand Up @@ -467,7 +468,7 @@ Waiting....

#### Delete database
```text
./crud -p -n localhost:50000 delete-db -u myuuid
./crud -s <SWARM-ID> -n localhost:50000 delete-db -u myuuid
Client: crud-script-0
------------------------------------------------------------
Expand Down Expand Up @@ -516,6 +517,8 @@ positional arguments:
optional arguments:
-h, --help show this help message and exit
-i ID, --id ID Crud script sender id (default 0)
-s <SWARM-ID>, Swarm id
--swarm_id <SWARM-ID>
required arguments:
-n NODE, --node NODE node's address (ex. 127.0.0.1:51010)
8 changes: 8 additions & 0 deletions scripts/crud
Expand Up @@ -38,6 +38,7 @@ except ImportError as e:
"$ protoc --python_out=../scripts ./*.proto\n".format(e.message))

nonce = 0
CRUD_SCRIPT_SWARM_ID = ""
CRUD_SCRIPT_SENDER_ID = "crud-script"

def handle_response(ws):
Expand All @@ -60,6 +61,7 @@ def handle_response(ws):

def send_request(node, uuid, msg, loop=False, ws=None):
global nonce
global CRUD_SCRIPT_SWARM_ID
global CRUD_SCRIPT_SENDER_ID

if not ws:
Expand All @@ -74,6 +76,7 @@ def send_request(node, uuid, msg, loop=False, ws=None):

msg_outer = bluzelle_pb2.bzn_envelope()
msg_outer.database_msg = msg.SerializeToString()
msg_outer.swarm_id = CRUD_SCRIPT_SWARM_ID
msg_outer.sender = CRUD_SCRIPT_SENDER_ID

ws.send_binary(msg_outer.SerializeToString())
Expand Down Expand Up @@ -102,6 +105,7 @@ def send_status_request(node):
ws = websocket.create_connection("ws://" + args.node)
msg_outer = bluzelle_pb2.bzn_envelope()
msg_inner = status_pb2.status_request()
msg_outer.swarm_id = CRUD_SCRIPT_SWARM_ID
msg_outer.sender = CRUD_SCRIPT_SENDER_ID
msg_outer.status_request = msg_inner.SerializeToString()

Expand Down Expand Up @@ -326,6 +330,8 @@ if __name__ == "__main__":

parser = ArgumentParser(description="crud", formatter_class=RawDescriptionHelpFormatter)

parser.add_argument("-s", "--swarm_id", type=str, default="0", help="Target swarm id (default 0)", required=False)

parser.add_argument("-i", "--id", type=str, default="0", help="Crud script sender id (default 0)", required=False)

required = parser.add_argument_group('required arguments')
Expand Down Expand Up @@ -480,6 +486,8 @@ if __name__ == "__main__":
# no input file specified. Value was passed via command line
pass

CRUD_SCRIPT_SWARM_ID = args.swarm_id

CRUD_SCRIPT_SENDER_ID += "-" + args.id
print("\nClient: " + CRUD_SCRIPT_SENDER_ID)

Expand Down

0 comments on commit 4422298

Please sign in to comment.