github.com/bhameyie/otto@v0.2.1-0.20160406174117-16052efa52ec/website/source/docs/concepts/deps.html.md (about) 1 --- 2 layout: "docs" 3 page_title: "Dependencies" 4 sidebar_current: "docs-concepts-deps" 5 description: |- 6 Application dependencies are a first class feature in Otto. 7 --- 8 9 # Dependencies 10 11 Application dependencies are a first class feature in Otto. 12 13 Modern applications often depend on many components. With the ever-growing 14 ["microservices"](http://martinfowler.com/articles/microservices.html) trend, 15 it isn't abnormal for an application to depend on dozens of other applications. 16 A common difficulty with microservices is development environments and 17 orchestrating deploys. Otto solves both of these problems. 18 19 For development environments, Otto automatically installs, configures, and 20 starts any dependencies of an application. For deploys, Otto ensures that 21 all the dependencies are deployed, can deploy those dependencies for you, 22 and doesn't duplicate dependency deploys across multiple applications. 23 24 ## Specifying Dependencies 25 26 Within the [Appfile](/docs/concepts/appfile.html), an application 27 can specify all of its dependencies. These dependencies can be other 28 applications, infrastructure components such as a queue, or external 29 services such as Datadog. 30 31 An application only needs to specify its immediate dependencies. If an 32 App "foo" depends on "bar", and "bar" depends on "baz", then the Appfile 33 for "foo" only needs to specify "bar." Otto is clever enough to discover that 34 "bar" depends on "baz" by inspecting the Appfiles of all the dependencies. 35 36 Dependencies are specified in the "application" block like so: 37 38 ``` 39 application { 40 name = "example" 41 type = "ruby" 42 43 dependency { 44 source = "github.com/hashicorp/otto/examples/mongodb" 45 } 46 } 47 ``` 48 49 The "source" string can be local path, HTTP URL, Git URL, and many more. 50 The full reference to dependency sources can be seen in the 51 [dependency sources](/docs/appfile/dep-sources.html) 52 page. 53 54 ## Compiling Dependencies 55 56 Dependencies are fetched during [compilation](/docs/concepts/compile.html). 57 They are not updated any other time. If an upstream dependency changes, 58 any downstream applications that want to bring in that change must 59 `otto compile`. 60 61 This functionality is very nice since it allows developers working on 62 a feature to not be impacted by potentially breaking changes upstream 63 until they're ready to. 64 65 Note that while downstream applications may not update their upstreams, 66 if the upstream dependency is already deployed, then any downstream 67 dependencies will see the new version of the dependency when deployed. 68 69 -> **A note on versioning:** Dependency versioning will be coming as a first class feature very 70 shortly into Otto, but isn't currently supported. For now, Otto will 71 always fetch whatever app is returned by the source URL. 72 73 ## Communicating with Dependencies 74 75 Whether in development or production, communicating with dependencies 76 is the same. Otto automatically deploys and manages a 77 [Consul](https://consul.io) cluster for service discovery. To find 78 a dependency, just use DNS with `appname.service.consul`. 79 80 For example, our example above with MongoDB can be reached at 81 `mongodb.service.consul`. For ports, dependencies must use well known 82 ports. A future version of Otto will do automatic port assignment 83 and expose that information via environment variables to the 84 application. 85 86 For more information on how Otto automatically sets this up, see 87 the [concepts page on "foundations"](/docs/concepts/foundations.html).