I've a web form that allows users to create clusters of three sizes: small, medium and large. The form is sending a string of small, medium or large to a message queue, were job dispatcher determines how many jobs (cluster elements) it should build for a given cluster, like that:
# determine required cluster size if cluster['size'] == 'small': jobs = 3 elif cluster['size'] == 'medium': jobs = 5 elif cluster['size'] == 'large': jobs = 8 else: raise ConfigError()
While it works, its very ugly and non flexible way of doing it - in case I'd want to have more gradual sizes, I'd increase number of
elif's. I could send a number instead of string straight from the form, but I dont want to place the application logic in the web app. Is there a nicer and more flexible way of doing something like that?