mount

wkf 2016-02-01T21:30:25.000119Z

Hello folks, I’m curious if there’s a good to handle indirect dependencies. For instance, I have a state that represents a connection to an SQS queue. In development, I’m using ElasticMQ to act as an SQS interface, and using a state to represent the server. Nothing depends on the namespace, but it must be loaded before SQS.

tolitius 2016-02-01T21:43:48.000120Z

@wkf: are you looking for a way to specify the order in which these states need to start?

wkf 2016-02-01T21:44:03.000121Z

yah

tolitius 2016-02-01T21:51:40.000122Z

this is something that I don't have an answer for yet :simple_smile: but definitely something we discussed before: i.e. "don't start subscribing events to an event bus, until the bus is started". in case of direct dependencies, this is not a problem, of course, since the compiler shares its intel. But in case of "one off" states, it is not very deterministic. there are 3 ways I currently use to achieve the desired order (for now, until we come up with a better solution): 1. Have namespaces with one offs to be required last in the entry point on the app 2. Use (mount/start-without a b c), and then do (mount/start) 3. If there are only a few states, you can do (mount/start e d a b c)

wkf 2016-02-01T21:52:31.000123Z

ahhh, interesting

wkf 2016-02-01T21:52:41.000124Z

thanks for the reply, I’ll have to see which strategy works best for me now

tolitius 2016-02-01T21:52:46.000125Z

#2 usually works great when there are many states to care about..

wkf 2016-02-01T21:52:50.000126Z

in my specific case, perhaps it’s better to always have some “queue” state

wkf 2016-02-01T21:53:03.000127Z

and just swap it out for an elasticmq backed queue

wkf 2016-02-01T21:53:04.000128Z

in development

tolitius 2016-02-01T21:56:44.000129Z

If I understand your use case correctly there are two questions there: #1 Not connecting to the real ElasticMQ in dev #2 Starting a server before connecting to the queue You can definitely go with swapping the ElasticMQ with a stub, but in case you do need it in development, something like (mount/start-without #'app/elastic-mq) and then (mount/start) will ensure that everything is started before #'app/elastic-mq

wkf 2016-02-01T21:57:43.000130Z

so, I use elasticmq only in dev to provide an SQS compatible API

wkf 2016-02-01T21:57:51.000131Z

in production, I use SQS

wkf 2016-02-01T21:58:05.000132Z

so I think in this case

wkf 2016-02-01T21:58:42.000133Z

I can (mount/start #’app/elasticmq) and then (mount/start) the rest of the application

wkf 2016-02-01T21:59:16.000134Z

ie, start the queue service

wkf 2016-02-01T21:59:20.000135Z

before consumers attempt to connect

tolitius 2016-02-01T21:59:32.000136Z

ah... "using ElasticMQ to act as an SQS interface" I missed that part :simple_smile:

tolitius 2016-02-01T22:00:09.000137Z

sure, if you need the queue to start before everything else

wkf 2016-02-01T22:00:58.000138Z

peerfect

wkf 2016-02-01T22:01:01.000139Z

thanks for the help :simple_smile:

tolitius 2016-02-01T22:01:17.000140Z

sure, very welcome

tolitius 2016-02-01T22:03:51.000141Z

depending on how your app is structured there might still be a problem though.. you do have both states defined: * #'app/elasticmq * #'app/realsqs so you might want to do something like: (mount/start #'app/elasticmq) and then (mount/start-with {#'app/realsqs #'app/elasticmq})