A way to configure a 'functional' component #945

Merged
merged 1 commit into from Dec 29, 2016

Projects

None yet

3 participants

@meejah
Member
meejah commented Dec 17, 2016 edited

Here is a (working) sketch of how to take a "functional"-style component and configure it into crossbar.

Basically, it's just configuring methods to call for the 4 listeners: connect, disconnect, join, leave.

This sketch only allows for single callbacks -- it might be nicer to allow a list of callbacks, too. To use this, you'd add something like this to a components list in crossbar config:

                {
                    "type": "function",
                    "realm": "crossbardemo",
                    "role": "anonymous",
                    "callbacks": {
                        "join": "func_component.on_join",
                        "leave": "func_component.on_leave",
                        "connect": "func_component.on_connect",
                        "disconnect": "func_component.on_disconnect"
                    }
                }

(So it might make sense to allow, e.g., "join": ["func_component.on_join", "some.other.module.joined_cb"])

@codecov-io
codecov-io commented Dec 17, 2016 edited

Current coverage is 54.24% (diff: 0.00%)

Merging #945 into master will decrease coverage by 0.09%

@@             master       #945   diff @@
==========================================
  Files           103        103          
  Lines         13959      13984    +25   
  Methods           0          0          
  Messages          0          0          
  Branches       2096       2104     +8   
==========================================
  Hits           7585       7585          
- Misses         5945       5969    +24   
- Partials        429        430     +1   

Powered by Codecov. Last update 4630514...75a98bc

@oberstet oberstet merged commit b713aaa into crossbario:master Dec 29, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@oberstet
Member

Yeah, allowing lists for handlers would allow to reap the benefits of using such a functional style. Maybe even have a variant where a module name is sufficient when using standard names for function therein (like "on_join", "on_leave", ..) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment