Yelp / pyleus

Pyleus is a Python framework for developing and launching Storm topologies.
Apache License 2.0
404 stars 113 forks source link

How to define global options in "pyleus_topology.yaml" for all components? #163

Open arnolddeng85 opened 8 years ago

arnolddeng85 commented 8 years ago

I want to define DB server info(host, port, etc.) which are used by all the spouts and bolts. But I think it is hard to maintain if I define the same DB server info at the options under all the components on "pyleus_topology.yaml". Such as:

    - spout:
        options:
               host: 192.168.0.1
               port: 3306
    - bolt:
        options:
               host: 192.168.0.1
               port: 3306
    - bolt:
        options:
               host: 192.168.0.1
               port: 3306

So how to define global options in "pyleus_topology.yaml" for all components and how to get the global options at component class code?

poros commented 8 years ago

Yeah, I agree that this is not ideal. I don't believe it's possible to use "variables" in YAML and there is no easy workaround I can think about.

Implementing a Python DSL for specifying topologies instead than just a YAML config file would easily solve this problem, but I don't believe there is any plan to do that for now. If you really care about this, you could write a tiny Python script to generate your YAML file and run it via your Makefile (I did that a couple of times, it's not great, but it works).

arnolddeng85 commented 8 years ago

OK. Thanks for your suggestion.