{"id":13755942,"url":"https://github.com/otto-de/tesla-microservice","last_synced_at":"2025-07-22T22:08:25.302Z","repository":{"id":26229415,"uuid":"29676123","full_name":"otto-de/tesla-microservice","owner":"otto-de","description":"Common basis for some of otto.de's clojure microservices","archived":false,"fork":false,"pushed_at":"2025-05-08T18:29:00.000Z","size":415,"stargazers_count":193,"open_issues_count":2,"forks_count":26,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-07-13T05:19:01.718Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/otto-de.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-01-22T11:45:07.000Z","updated_at":"2025-05-08T18:29:04.000Z","dependencies_parsed_at":"2024-01-18T11:39:47.736Z","dependency_job_id":"c08ba5f2-6db6-47e5-8177-5b8268c11192","html_url":"https://github.com/otto-de/tesla-microservice","commit_stats":{"total_commits":387,"total_committers":29,"mean_commits":"13.344827586206897","dds":0.7803617571059431,"last_synced_commit":"9479f1aeddeaa7d79815147c694be1aa002d0fd6"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"purl":"pkg:github/otto-de/tesla-microservice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otto-de%2Ftesla-microservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otto-de%2Ftesla-microservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otto-de%2Ftesla-microservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otto-de%2Ftesla-microservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/otto-de","download_url":"https://codeload.github.com/otto-de/tesla-microservice/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otto-de%2Ftesla-microservice/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266580865,"owners_count":23951304,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T11:00:33.193Z","updated_at":"2025-07-22T22:08:25.280Z","avatar_url":"https://github.com/otto-de.png","language":"Clojure","funding_links":[],"categories":["Service Toolkits"],"sub_categories":["JVM","Java VM"],"readme":"# tesla-microservice\n\n\u003e \"If Edison had a needle to find in a haystack, he would proceed at once with the diligence of the bee to examine straw after straw until he found the object of his search.\" - Nikola Tesla\n\nThis is the common basis for some of otto.de's microservices. It is written in clojure using the [component framework](https://github.com/stuartsierra/component).\n\n[![Clojars Project](http://clojars.org/de.otto/tesla-microservice/latest-version.svg)](http://clojars.org/de.otto/tesla-microservice)\n\n[![Build Status](https://travis-ci.org/otto-de/tesla-microservice.svg)](https://travis-ci.org/otto-de/tesla-microservice)\n[![Dependencies Status](http://jarkeeper.com/otto-de/tesla-microservice/status.svg)](http://jarkeeper.com/otto-de/tesla-microservice)\n\n\n## Breaking changes\n\n_tesla-microservice_ is used for a number of different services now. Still it is a work in progress. See [CHANGES.md](./CHANGES.md) for instructions on breaking changes.\n\n## Features included\n\n* Load configuration from filesystem.\n* Aggregate a status.\n* Execute functions with a scheduler\n* Reply to a health check.\n* Deliver a json status report.\n* Report to graphite using the metrics library.\n* Manage handlers using ring.\n* Optional auto-hot-reloading of changed source files\n* Shutdown gracefully. If necessary delayed, so load-balancers have time to notice.\n\n## Examples\n\n* A growing set of example applications can be found at [tesla-examples](https://github.com/otto-de/tesla-examples).\n* David \u0026 Germán created an example application based, among other, on tesla-microservice. They wrote a very instructive [blog post about it](http://blog.agilityfeat.com/2015/03/clojure-walking-skeleton/)\n* Moritz created [tesla-pubsub-service](https://bitbucket.org/DerGuteMoritz/tesla-pubsub-service). It showcases how to connect components via core.async channels. Also the embedded jetty was replaced by immutant.\n\n### Scheduler\n\nThe scheduler wraps a thread-pool which can be used for scheduling tasks. It is based on [overtones at-at](https://github.com/overtone/at-at) project.\nTo actually use it you have to pass the `:scheduler` as a dependency to the component in which it should be used.\nAfterwards you can schedule tasks using the overtone api like this:  \n```clj\n(overtone.at-at/every 100 #(println \"Hello world\") (de.otto.tesla.stateful.scheduler/pool scheduler) :desc \"HelloWord Task\")\n```\n\nThe overtone-pool wrapped by the scheduler can be configured by the config-entry `:scheduler`. (See `overtone.at-at/mk-pool`)\nBy default the pool holds no threads.\n\n### app-status\n\nThe app-status indicates the current status of your microservice. To use it you can register a status function to it.\n\nHere is a simple example for a function that checks if an atom is empty or not.\n\n```clj\n(de.otto.tesla.stateful.app-status/register-status-fun app-status #(status atom))\n``` \n\nThe `app-status` is injected under the keyword :app-status from the base system.\n\n```clj\n(defn status [atom]\n      (let [status (if @atom :error :ok)\n            message (if @atom \"Atom is empty\" \"Atom is not empty\")]\n           (de.otto.status/status-detail :status-id status message)))\n```\n\nFor further information and usages take a look at the: [status library](https://github.com/otto-de/status)\n\n## Choosing a server\n\nAs of version ```0.1.15``` there is no server included any more directly in _tesla-microservice_. \nThis gives you the freedom to  a) not use any server at all (e.g. for embedded use) b) choose another server e.g. a non-blocking one like httpkit or immutant. The available options are:\n\n* [tesla-jetty](https://github.com/otto-de/tesla-jetty): The tried and tested embedded jetty.\n* [tesla-httpkit](https://github.com/otto-de/tesla-httpkit): The non-blocking httpkit. \n\n## Configuring\n\nApplications build with `tesla-microservices` can be configured via \n`edn`-files, that have to be located in the class path.\n\nFor backwards compatibility, it is also possible to load config from `properties`-files. \nSee below for noteworthy differences.\n \n\n### Order of loading and merging\n\n1. A file named `default.edn` is loaded as a resource from classpath if present. \n2. A file either named `application.edn` or overridden by the ENV-variable `$CONFIG_FILE`\n is loaded as a resource or, if that is not possible, from the filesystem.\n3. A file name `local.edn` is loaded from classpath if present.\n\nThe configuration hash-map in those files is loaded and merged in the\nspecified order. Which mean configurations for the same key is overridden\nby the latter occurrence.\n\n### ENV-variables\n\nIn contrast to former versions of `tesla-microservice` ENV-variables are not\nmerged into the configuration.\n\nBut you can easily specify ENV-variables, that should be accessible in\nyour configuration:\n\n```edn\n{\n :my-app-secret  #ts/env [:my-env-dep-app-secret \"default\"]\n}\n```\n\nENV-variables are read with [environ](https://github.com/weavejester/environ). To see\nwhich keyword represents which ENV-var have a look in their docs. \n\n### Configuring via properties files\n\nFor backwards compatibility, it is also possible to load config from `properties`-files. \nYou'll have to pass `{:property-file-preferred true}` as a runtime config to the base-system.\nIt is not possible to load individual environment variables when using properties config. \nAdding `:merge-env-to-properties-config true` to the runtime config will add all system properties\nand environment variables, overiding any config from files.\n\n### Reporters\nApplications utilizing Tesla-Microservice can use [iapetos prometheus client](https://github.com/xsc/iapetos) for monitoring.\nMetrics are send by reporters which can be configured using the `:metrics` keyword.\nEach configured reporter will start at system startup automatically.\n\nSee example configuration below for all supported reporters.\n\n```clojure\n:metrics {:graphite            {:host             \"localhost\"\n                                :port             \"2003\"\n                                :prefix           \"my.prefix\"\n                                :interval-in-s    60\n                                :include-hostname :first-part}\n          :prometheus          {:metrics-path \"/metrics\"}}\n```\n\n## Automatic hot-reloading of changed source files\n\nRestarting the whole system after a small change can be cumbersome.\nA _tesla-microservice_ can detect changes to your source files and \nload them into a running server. Add this to your config, to check\nfor changes on each request to your system: \n\n```edn\n{:handler {:hot-reload? true}}\n```\n\n_Note_: This should only be enabled in development mode. \nUse your `local.edn` to enable this feature safely.\nYou can add a `private.edn` as well for personal configurations. This file should be added to your `.gitignore`.\n\n## Securing internal info endpoints\nThe Tesla-Microservice comes with endpoints that hold information about the internal state of your application.\nThose endpoints can be the app-status or even metrics (Prometheus, see above).\nTo secure those endpoints you can provide an authentication-middleware to the base-system. \n\nE.g.:\n\n```clojure\n(defn auth-middleware [config handler-fn]\n  (fn [request] (if (authenticated? config request) \n                  (handler-fn request)\n                  {:status 401 :body \"access denied\"})))\n\n(defn example-system [runtime-config]\n  (-\u003e (de.otto.tesla.system/base-system runtime-config auth-middleware))) \n```\n\n## Addons\n\nThe basis included is stripped to the very minimum. Additional functionality is available as addons:\n\n* [tesla-zookeeper-observer](https://github.com/otto-de/tesla-zookeeper-observer): Read only access to zookeeper.\n* [tesla-mongo-connect](https://github.com/otto-de/tesla-mongo-connect): Read/write access to mongodb.\n* [tesla-cachefile](https://github.com/otto-de/tesla-cachefile): Read and write a cachefile. Locally or in hdfs.\n\nMore features will be released at a later time as separate addons.\n\n## FAQ\n\n**Q:** Is it any good? **A:** Yes.\n\n**Q:** Why tesla? **A:** It's a reference to the ingenious scientist and inventor.\n\n**Q:** Are there alternatives? **A:** Yes. You might want to look at [modularity.org](https://modularity.org/), [system](https://github.com/danielsz/system) and [duct](https://github.com/weavejester/duct).\n\n\n\n## Initial Contributors\n\nChristian Stamm, Felix Bechstein, Ralf Sigmund, Kai Brandes, Florian Weyandt\n\n## License\nReleased under [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotto-de%2Ftesla-microservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fotto-de%2Ftesla-microservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotto-de%2Ftesla-microservice/lists"}