Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic remote procedure call #25

Closed
5 tasks done
dahlia opened this issue Jul 19, 2016 · 1 comment
Closed
5 tasks done

Basic remote procedure call #25

dahlia opened this issue Jul 19, 2016 · 1 comment
Assignees
Labels
cat:lang Category: Language design cmp:compiler Component: Compiler backend (e.g., annotation processors, code generators) target:python typ:enhance Type: Enhancement/new feature

Comments

@dahlia
Copy link
Member

dahlia commented Jul 19, 2016

Primary remote procedure call has to be implemented:

// syntax has to be discussed more

boxed token (uuid);
union key = phone       (text phone_number)
          | qr-code     (text url)
          | credit-card (blob hash)
          ;
service customer (
    "GET /tokens/<token>/key/"
    key get-key-by-token (token token),
    "GET /tokens/groups/"
    {{token}} group-tokens ({token} tokens),
);
// client
class CustomerServiceClient {
    Future<Key> getKeyByToken(Future<Token> token);
    Future<Key> getKeyByToken(Token token);
    Future<Set<Set<Token>>> groupTokens(Future<Set<Token>> tokens);
    Future<Set<Set<Token>>> groupTokens(Set<Token> tokens);
}
CustomerService client = new CustomerServiceClient("https://customer.internal.spoqa.com/");
Key key = client.getKeyByToken(token);
// server
interface CustomerService {
    Key getKeyByToken(Token token);
    Set<Set<Token>> groupTokens(Set<Token> tokens);
}
class CustomerServiceImpl implements CustomerService {
    CustomerServiceImpl(Callable<Session> createSession) {
        this.session = session;
    }
    Key getKeyByToken(Token token) {
        // sql logic..
    }
    Set<Set<Token>> groupTokens(Set<Token> tokens) {
        // sql logic..
    }
}
new nirum.rpc.HttpServer<CustomerService>(
    new CustomerServiceImpl(getCurrentSession)
);
from nirum.rpc import WsgiApp
from werkzeug.wsgi import DispatcherMiddleware
from waitress import serve
app = DispatcherMiddleware({
    '/customer': WsgiApp(CustomerServiceImpl(get_session)),
    '/store': ...
})
serve(app, '', 8080)

Prerequisites:

@dahlia
Copy link
Member Author

dahlia commented Mar 24, 2017

Basic RPC was implemented except of manual URL routing. Close this, and open a separated issue #130.

@dahlia dahlia closed this as completed Mar 24, 2017
@dahlia dahlia added cat:docs Category: Documentation cat:lang Category: Language design cmp:compiler Component: Compiler backend (e.g., annotation processors, code generators) target:python and removed cat:docs Category: Documentation labels Aug 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:lang Category: Language design cmp:compiler Component: Compiler backend (e.g., annotation processors, code generators) target:python typ:enhance Type: Enhancement/new feature
Projects
None yet
Development

No branches or pull requests

2 participants