Module jumpscale.servers.gedis.example_actor
Expand source code
from jumpscale.servers.gedis.baseactor import BaseActor, actor_method
from typing import Sequence
from jumpscale.loader import j
import inspect, sys
class TestObject:
    def __init__(self):
        self.attr = None
    def to_dict(self):
        return self.__dict__
    def from_dict(self, ddict):
        self.__dict__ = ddict
class Example(BaseActor):
    @actor_method
    def add_two_ints(self, x: int, y: int) -> int:
        """Adds two ints
        Arguments:
            x {int} -- first int
            y {int} -- second int
        Returns:
            int -- the sum of the two ints
        """
        return x + y
    @actor_method
    def concate_two_strings(self, x: str, y: str) -> str:
        """Concate two strings
        Arguments:
            x {str} -- first string
            y {str} -- second string
        Returns:
            str -- the concate of the two strings
        """
        return x + y
    @actor_method
    def modify_object(self, myobj: list, new_value: int) -> list:
        """Modify atrribute attr of the given object
        Arguments:
            myobj {TestObject} -- the object to be modified
        Returns:
            TestObject -- modified object
        """
        for i in range(len(myobj)):
            myobj[i].attr = new_value * (i + 1)
        return myobj
Actor = ExampleClasses
- class Example
- 
Expand source codeclass Example(BaseActor): @actor_method def add_two_ints(self, x: int, y: int) -> int: """Adds two ints Arguments: x {int} -- first int y {int} -- second int Returns: int -- the sum of the two ints """ return x + y @actor_method def concate_two_strings(self, x: str, y: str) -> str: """Concate two strings Arguments: x {str} -- first string y {str} -- second string Returns: str -- the concate of the two strings """ return x + y @actor_method def modify_object(self, myobj: list, new_value: int) -> list: """Modify atrribute attr of the given object Arguments: myobj {TestObject} -- the object to be modified Returns: TestObject -- modified object """ for i in range(len(myobj)): myobj[i].attr = new_value * (i + 1) return myobjAncestorsMethods- def add_two_ints(self, x: int, y: int) ‑> int
- 
Adds two ints Argumentsx {int} – first int y {int} – second int Returnsint – the sum of the two ints Expand source code@actor_method def add_two_ints(self, x: int, y: int) -> int: """Adds two ints Arguments: x {int} -- first int y {int} -- second int Returns: int -- the sum of the two ints """ return x + y
- def concate_two_strings(self, x: str, y: str) ‑> str
- 
Concate two strings Argumentsx {str} – first string y {str} – second string Returnsstr – the concate of the two strings Expand source code@actor_method def concate_two_strings(self, x: str, y: str) -> str: """Concate two strings Arguments: x {str} -- first string y {str} -- second string Returns: str -- the concate of the two strings """ return x + y
- def modify_object(self, myobj: list, new_value: int) ‑> list
- 
Modify atrribute attr of the given object Argumentsmyobj {TestObject} – the object to be modified ReturnsTestObject – modified object Expand source code@actor_method def modify_object(self, myobj: list, new_value: int) -> list: """Modify atrribute attr of the given object Arguments: myobj {TestObject} -- the object to be modified Returns: TestObject -- modified object """ for i in range(len(myobj)): myobj[i].attr = new_value * (i + 1) return myobj
 
- class Actor
- 
Expand source codeclass Example(BaseActor): @actor_method def add_two_ints(self, x: int, y: int) -> int: """Adds two ints Arguments: x {int} -- first int y {int} -- second int Returns: int -- the sum of the two ints """ return x + y @actor_method def concate_two_strings(self, x: str, y: str) -> str: """Concate two strings Arguments: x {str} -- first string y {str} -- second string Returns: str -- the concate of the two strings """ return x + y @actor_method def modify_object(self, myobj: list, new_value: int) -> list: """Modify atrribute attr of the given object Arguments: myobj {TestObject} -- the object to be modified Returns: TestObject -- modified object """ for i in range(len(myobj)): myobj[i].attr = new_value * (i + 1) return myobjAncestorsMethods- def add_two_ints(self, x: int, y: int) ‑> int
- 
Adds two ints Argumentsx {int} – first int y {int} – second int Returnsint – the sum of the two ints Expand source code@actor_method def add_two_ints(self, x: int, y: int) -> int: """Adds two ints Arguments: x {int} -- first int y {int} -- second int Returns: int -- the sum of the two ints """ return x + y
- def concate_two_strings(self, x: str, y: str) ‑> str
- 
Concate two strings Argumentsx {str} – first string y {str} – second string Returnsstr – the concate of the two strings Expand source code@actor_method def concate_two_strings(self, x: str, y: str) -> str: """Concate two strings Arguments: x {str} -- first string y {str} -- second string Returns: str -- the concate of the two strings """ return x + y
- def modify_object(self, myobj: list, new_value: int) ‑> list
- 
Modify atrribute attr of the given object Argumentsmyobj {TestObject} – the object to be modified ReturnsTestObject – modified object Expand source code@actor_method def modify_object(self, myobj: list, new_value: int) -> list: """Modify atrribute attr of the given object Arguments: myobj {TestObject} -- the object to be modified Returns: TestObject -- modified object """ for i in range(len(myobj)): myobj[i].attr = new_value * (i + 1) return myobj
 
- class TestObject
- 
Expand source codeclass TestObject: def __init__(self): self.attr = None def to_dict(self): return self.__dict__ def from_dict(self, ddict): self.__dict__ = ddictMethods- def from_dict(self, ddict)
- 
Expand source codedef from_dict(self, ddict): self.__dict__ = ddict
- def to_dict(self)
- 
Expand source codedef to_dict(self): return self.__dict__