@@ -260,7 +260,7 @@ def _remove_upstream(self, upstream):
260260 self .upstreams .remove (upstream )
261261
262262 @classmethod
263- def register_api (cls , modifier = identity ):
263+ def register_api (cls , modifier = identity , attribute_name = None ):
264264 """ Add callable to Stream API
265265
266266 This allows you to register a new method onto this class. You can use
@@ -290,10 +290,21 @@ def _(func):
290290 @functools .wraps (func )
291291 def wrapped (* args , ** kwargs ):
292292 return func (* args , ** kwargs )
293- setattr (cls , func .__name__ , modifier (wrapped ))
293+ name = attribute_name if attribute_name else func .__name__
294+ setattr (cls , name , modifier (wrapped ))
294295 return func
295296 return _
296297
298+ @classmethod
299+ def register_plugin_entry_point (cls , entry_point , modifier = identity ):
300+ def stub (* args , ** kwargs ):
301+ attribute = entry_point .load ()
302+ cls .register_api (
303+ modifier = modifier , attribute_name = entry_point .name
304+ )(attribute )
305+ return attribute (* args , ** kwargs )
306+ cls .register_api (modifier = modifier , attribute_name = entry_point .name )(stub )
307+
297308 def start (self ):
298309 """ Start any upstream sources """
299310 for upstream in self .upstreams :
0 commit comments