question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App wrapper on top of ApplicationRunner

See original GitHub issue

From: https://groups.google.com/forum/#!topic/autobahnws/lmztderi6N4

What I think is the biggest adoption issue, however, is the API. Autobahn should have a small cost of entry, and right now it doesnt. The hello world is not only hard to write using the documentation, but quite scary :

  from  twisted.python  import  log
  from  twisted.internet.defer  import  inlineCallbacks

  from  autobahn.twisted.wamp  import  ApplicationSession
  from  autobahn.twisted.wamp  import  ApplicationRunner


  class  ListenForEvent(ApplicationSession):


       def  __init__(self, config):
           ApplicationSession.__init__(self)
           self.config  = config

       def  onConnect(self):
           self.join(self.config.realm)


       @inlineCallbacks
       def  onJoin(self, details):
           callback =lambda  x: log.msg("Received event %s"  %  x)
           yield  self.subscribe(callback,'un_evenement')


  if  __name__ =='__main__':
      runner = ApplicationRunner(endpoint="tcp:127.0.0.1:8080",
                                 url="ws://localhost:8080/ws",
                                 realm="realm1")
      runner.run(ListenForEvent)

We need a simplified wrapper for that, that can be used for simple use case : small applications, tests, etc. In the same fashion that flask and bottle make web programming much easier than Django. I’m suggesting to add something like this :

  from  autobahn.app  import  App

  app = App(url="ws://localhost:8080/ws")

  @event("event_name")
  def  handle(details):
       app.log("Received event %s"  %  details)

  if  __name__ =='__main__':
      app.run()

Sane defaults, doesn’t not cover all the use cases, but it’s enought for 80% of the dev. The goal is not to replace the other API, but rather offer something higher level we can show of in the first page of the documentation that would make people started quickly.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:44 (41 by maintainers)

github_iconTop GitHub Comments

1reaction
oberstetcommented, Mar 23, 2018
0reactions
petercsmithcommented, Jun 8, 2015

@DenJohX Agreed, not being able to automatically reconnect a python client (using ApplicationRunner) to crossbar.io is blocking me from using Autobahn. Is there a workaround?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Boot Runners - ApplicationRunner and ... - amitph
A Guide to Spring Boot Runners – Application Runner and Command Line Runners – with the help of examples. Tutorial Contents. What is...
Read more >
23. SpringApplication
The SpringApplication class provides a convenient way to bootstrap a Spring application that is started from a main() method. In many situations, you...
Read more >
When and why do we need ApplicationRunner and Runner ...
ApplicationRunner and CommandLineRunner are two interfaces Spring Boot provides to run any custom code just before application is fully started.
Read more >
Build a Basic App with Spring Boot and JPA using PostgreSQL
On top of that, you're going to implement a group-based ... Spring Data JPA is a wrapper around JPA providers such as Hibernate....
Read more >
Build a CRUD App With Spring Boot and Angular in 20 Minutes
Learn how to create a basic CRUD app using Spring Boot and Angular ... @Bean ApplicationRunner init(BookRepository repository) { // Save our ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found