0.1.86 • Published 1 year ago

telekinesis-js v0.1.86

Weekly downloads
1
License
MIT
Repository
github
Last release
1 year ago

Telekinesis

noun the ability to move objects by means of thought alone internet communication, without physical means;

Basic Idea

Telekinesis is built on the premise that developing, publishing and calling services across the internet shouldn't be fundamentally different to writing local code.

With Telekinesis, to create a new service, just write a function or class and publish it to a hub:

# Example: stateless service (function):
def hello(name='world'):
    # Document your services with docstrings, default values and good argument names
    return 'Hello ' + str(name)

# Publish and serve your new service in the telekinesis.cloud `hub` in one line:
service_hello = await node.publish('<your-username>/hello', hello)

To call this new service (on a separate computer), just get it from the hub and call it:

hello = await node.get('<your-username>/hello')

# This should print 'Hello Awesome':
print(await hello('Awesome'))

Moreover, if you want to create a more complex service (i.e. with state and multiple methods), use classes:

# define a stateful service (object):
class Counter:
    def __init__(self, initial_value=0):
        self.value = initial_value
    def increment(self, amount=1):
        self.value += amount
        return self.value

service_counter = await node.publish('<your-username>/Counter', Counter)

Then on the client side:

Counter = await node.get('<your-username>/Counter')

# This instantiates the object
counter = await Counter(123)

# This should print 123:
print(counter.value)

# This should print 223:
print(await counter.increment(100))

Main Features

  • Open Source: You can use it anywhere you like, look under the hood, find security issues (please do!), suggest changes, fork it... do anything you want. I just hope you find this useful!
  • Low latency: Telekinesis is based on websocket communication, so SSL and authorization verification occurs at the connection initialization stage; service requests and responses send a single network package - no back and forth.
  • Role based authorization: Telekinesis has a hierarchical, role-based, authorization system, which limits who can call and serve each service, making the services themselves simpler. DO NOT TRUST YET!
  • Limited surface area: The client doesn't have to trust the code of the service provider and viceversa. The computation runs entirely on the service provider side, so the only the service signature and the arguments passed are shared. Moreover, the service can have any dependencies and secrets the developer needs.
  • No network set-up: Once a hub is set-up and running, all the services created can start working, without having to set up ports, SSL or DNS.
  • Services feel local: Telekinesis makes the service instances on the client side feel like local code, maintaining the argument names, default values and docstrings.

Disclaimer

This is a PROTOTYPE, nobody has AUDITED this code yet, so:

  • DO NOT TRUST with critical/confidential data.
  • DO NOT TRUST with personal passwords.
  • API will likely change and break your code!

Getting Started

Installation:

pip install telekinesis

Connect to the telekinesis.cloud hub:

from telekinesis import Node

# Connect to a Telekinesis `hub`
node = await Node('wss://telekinesis.cloud').connect()

# telekinesis.cloud has `sign_up` and `sign_in` services to authenticate 

# If you've never signed up, get and call the sign_up service:
sign_up = await node.get('sign_up')

# This prompts you for username and password to create your user:
await sign_up()

# Get the sign_in service:
sign_in = await node.get('sign_in')

# This prompts you for username and password and checks it matches with the one you signed up with:
assert await sign_in() 

# Create a sample service: 
service_hello = await node.publish('<your-username>/hello', lambda name='World': 'Hello '+ str(name))

# Get this service (you would normally do this in a different computer/script):
hello = await node.get('<your-username>/hello')

# This should print 'Hello Awesome':
print(await hello('Awesome'))

# To remove a service just call its remove method:
await service_hello.remove()

Run a simple Telekinesis hub:

from telekinesis import Hub

# Start a local Telekinesis `hub`
hub = await Hub().start()

# By default the hub runs in 'ws://localhost:3388' (same url the Node connects to by default)

Note: This simple hub doesn't have the authorization layer activated. You can check out examples/telekinesis_cloud_website/server.py and examples/telekinesis_cloud_website/services/sign_in.py to see how the role based authorization system is leveraged.

API Reference

Telekinesis is still in early development, so the API is likely to change, and therefore its documentation will grow stale quickly.

The best reference (for now) to check the functionality are the tests at python/test.

Each test is self contained and demonstrates one key functionality (i.e. having multiple workers for a service, delegating roles, etc).

Also, make sure to check the examples directory.

Contribute

If you are interested in this concept, you can contribute by:

  • Proposing API name changes (I'd rather make breaking changes now than later!)
  • Finding bugs and security holes
  • Submitting issues
  • Adding tests (see python/test directory)
  • Creating examples
  • Helping with the docstrings

Any help is very appreciated!

You can also register your email at https://telekinesis.cloud to be notified for updates (this also helps me gauge interest)

0.1.85

1 year ago

0.1.86

1 year ago

0.1.80

1 year ago

0.1.81

1 year ago

0.1.82

1 year ago

0.1.84

1 year ago

0.1.74

1 year ago

0.1.75

1 year ago

0.1.76

1 year ago

0.1.77

1 year ago

0.1.78

1 year ago

0.1.79

1 year ago

0.1.73

1 year ago

0.1.70

2 years ago

0.1.71

2 years ago

0.1.72

2 years ago

0.1.63

2 years ago

0.1.64

2 years ago

0.1.65

2 years ago

0.1.66

2 years ago

0.1.67

2 years ago

0.1.68

2 years ago

0.1.69

2 years ago

0.1.62

2 years ago

0.1.57

2 years ago

0.1.58

2 years ago

0.1.59

2 years ago

0.1.60

2 years ago

0.1.61

2 years ago

0.1.52

2 years ago

0.1.53

2 years ago

0.1.54

2 years ago

0.1.55

2 years ago

0.1.56

2 years ago

0.1.50

2 years ago

0.1.51

2 years ago

0.1.49

2 years ago

0.1.47

2 years ago

0.1.48

2 years ago

0.1.41

3 years ago

0.1.43

3 years ago

0.1.44

3 years ago

0.1.45

3 years ago

0.1.46

3 years ago

0.1.40

3 years ago

0.1.38

3 years ago

0.1.39

3 years ago

0.1.34

3 years ago

0.1.35

3 years ago

0.1.36

3 years ago

0.1.37

3 years ago

0.1.31

3 years ago

0.1.32

3 years ago

0.1.33

3 years ago

0.1.30

3 years ago

0.1.27

3 years ago

0.1.28

3 years ago

0.1.29

3 years ago

0.1.20

3 years ago

0.1.21

3 years ago

0.1.22

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.1.25

3 years ago

0.1.26

3 years ago

0.1.17

3 years ago

0.1.18

3 years ago

0.1.19

3 years ago

0.1.15

3 years ago

0.1.16

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.1.0-alpha.21

4 years ago

0.1.0-alpha.20

4 years ago

0.1.0-alpha.9

4 years ago

0.1.0-alpha.8

4 years ago

0.1.0-alpha.19

4 years ago

0.1.0-alpha.7

4 years ago

0.1.0-alpha.5

4 years ago

0.1.0-alpha.4

4 years ago

0.1.0-alpha.6

4 years ago

0.1.0-alpha.1

4 years ago

0.1.0-alpha.3

4 years ago

0.1.0-alpha.2

4 years ago

0.1.0-alpha.0

4 years ago

0.1.0-alpha.18

4 years ago