Пример #1
0
from space_api import API

api = API("books-app", "localhost:4124")
# Call a function, 'my-func' of 'my-engine' running on backend
response = api.call('my-engine', 'my-func', {"msg": 'Space Cloud is awesome!'},
                    1000)
if response.status == 200:
    print(response.result)
else:
    print(response.error)
Пример #2
0
from space_api import API

api = API('books-app', 'localhost:4124')

for i in range(100):
    response = api.call('service', 'echo_func', 'param' + str(i), timeout=5000)
    print(response)

api.close()
Пример #3
0
from space_api import API
import random
import time
import variables

api = API(variables.app, variables.url)

while True:
    response = api.call('service', 'echo_func', 'param' + str(random.randint(1,100)), timeout=5)
    print(response)
    time.sleep(0.01)

api.close()
Пример #4
0
from space_api import API

api = API('books-app', 'localhost:4124')


def my_func(params, auth, cb):  # Function to be registered
    print("Params", params, "Auth", auth)

    # Do Something
    cb('response', {"ack": True})


service = api.service('service')  # Create an instance of service
service.register_func('my_func', my_func)  # Register function
service.start()  # Start service

# Call function of some other service
response = api.call('some_service',
                    'some_func', {"msg": "space-service-go is awesome!"},
                    timeout=5)
print(response)

api.close()