{"id":15285821,"url":"https://github.com/am-kantox/johanna","last_synced_at":"2026-01-05T11:50:06.399Z","repository":{"id":57509237,"uuid":"86726934","full_name":"am-kantox/johanna","owner":"am-kantox","description":"erlcron smart wrapper :: cron for elixir","archived":false,"fork":false,"pushed_at":"2017-04-06T11:50:35.000Z","size":54,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-15T01:55:48.475Z","etag":null,"topics":["cron","cron-jobs","cronjob","elixir","elixir-lang","erlang"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/am-kantox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-30T16:54:34.000Z","updated_at":"2022-10-29T18:44:27.000Z","dependencies_parsed_at":"2022-08-30T07:11:04.441Z","dependency_job_id":null,"html_url":"https://github.com/am-kantox/johanna","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/am-kantox%2Fjohanna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/am-kantox%2Fjohanna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/am-kantox%2Fjohanna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/am-kantox%2Fjohanna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/am-kantox","download_url":"https://codeload.github.com/am-kantox/johanna/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245168912,"owners_count":20571804,"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","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":["cron","cron-jobs","cronjob","elixir","elixir-lang","erlang"],"created_at":"2024-09-30T15:07:45.573Z","updated_at":"2026-01-05T11:50:06.372Z","avatar_url":"https://github.com/am-kantox.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Johanna\n\n[![Johanna Build Status](https://travis-ci.org/am-kantox/johanna.svg?branch=master)](https://travis-ci.org/am-kantox/johanna) ⇒ This project, orchestrating the processes and performing all the routine tasks to keep the environment clean and robust, is named after and dedicated to **Johanna**, to honor the best office manager I ever worked with.\n\n## Installation\n\nIf [available in Hex](https://hex.pm/docs/publish), the package can be installed\nby adding `johanna` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:johanna, \"~\u003e 0.1\"}]\nend\n```\nWrapper for [`erlcron`](https://github.com/erlware/erlcron) with some smartness and goodness.\n\n## Using\n\n### Simple `cron`-like behaviour\n\n```elixir\nJohanna.at({3, :pm}, fn -\u003e IO.puts \"Fridge cleaning time!\" end)\n\nJohanna.once(10, fn -\u003e IO.puts \"New sushi menu!\" end)\n\nJohanna.every(10, fn -\u003e IO.puts(\"¡Yay!\") end)\nJohanna.every({10, :sec}, fn -\u003e IO.puts(\"¡Yay!\") end) # same as above\nJohanna.every({1, :min}, {IO, :puts, [\"¡Yay!\"]}) # `apply` notation\nJohanna.every({1, :hr}, {:between, {1, :pm}, {4, :pm}}, fn -\u003e IO.puts(\"¡Siesta!\") end)\n\n### Experimental:\nref = Johanna.at {7, :pm}, {IO, :puts, [\"Yay\"]}\n#⇒ #Reference\u003c0.0.5.28\u003e\nJohanna.replace ref, {{:daily, {7, :pm}}, {IO, :puts, [\"Yay\"]}}\n#⇒ #Reference\u003c0.0.5.28\u003e\n```\n\n### Make the task to retry until succeded\n\nIt’s easier to see by example. Here we declare a contrived function, that\nfails for 100 seconds approx and then succeeds:\n\n```elixir\ndefmodule Test do\n  @now NaiveDateTime.utc_now\n\n  def test do\n    # make it succeed 100 seconds later\n    case NaiveDateTime.compare(NaiveDateTime.utc_now, NaiveDateTime.add(@now, 100)) do\n      :lt -\u003e {:error, \":-(\"}\n      _ -\u003e {:ok, \":-)\"}\n    end\n  end\nend\nJohanna.start(nil, nil)\nJohanna.Service.care %Johanna.Message{caller: {Test, :test, []}}\nJohanna.Service.jobs\n#⇒ %{#Reference\u003c0.0.4.45\u003e =\u003e %Johanna.Message{attempts: [{%DateTime{calendar: Calendar.ISO,\n#      day: 5, hour: 16, microsecond: {799580, 6}, minute: 12, month: 4,\n#      second: 28, std_offset: 0, time_zone: \"Etc/UTC\", utc_offset: 0,\n#      year: 2017, zone_abbr: \"UTC\"},\n#     %Johanna.Service.ExecutedNotOk{caller: {Test, :test, []},\n#      message: \":-(\"}}], bag: [], caller: {Test, :test, []}, error: nil,\n#   message: nil, result: nil,\n#   time: %DateTime{calendar: Calendar.ISO, day: 5, hour: 13,\n#    microsecond: {245363, 6}, minute: 31, month: 4, second: 26, std_offset: 0,\n#    time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017, zone_abbr: \"UTC\"},\n#   type: {:retry, 3}}}\n\n# PAUSE FOR ≈60 SECONDS\n\nJohanna.Service.jobs\n#⇒ %{#Reference\u003c0.0.4.45\u003e =\u003e %Johanna.Message{attempts: [{%DateTime{calendar: Calendar.ISO,\n#      day: 5, hour: 16, microsecond: {808563, 6}, minute: 13, month: 4,\n#      second: 13, std_offset: 0, time_zone: \"Etc/UTC\", utc_offset: 0,\n#      year: 2017, zone_abbr: \"UTC\"},\n#     %Johanna.Service.ExecutedNotOk{caller: {Test, :test, []}, message: \":-(\"}},\n#    {%DateTime{calendar: Calendar.ISO, day: 5, hour: 16,\n#      microsecond: {807548, 6}, minute: 12, month: 4, second: 49, std_offset: 0,\n#      time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017, zone_abbr: \"UTC\"},\n#     %Johanna.Service.ExecutedNotOk{caller: {Test, :test, []}, message: \":-(\"}},\n#    {%DateTime{calendar: Calendar.ISO, day: 5, hour: 16,\n#      microsecond: {807267, 6}, minute: 12, month: 4, second: 37, std_offset: 0,\n#      time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017, zone_abbr: \"UTC\"},\n#     %Johanna.Service.ExecutedNotOk{caller: {Test, :test, []}, message: \":-(\"}},\n#    {%DateTime{calendar: Calendar.ISO, day: 5, hour: 16,\n#      microsecond: {800534, 6}, minute: 12, month: 4, second: 31, std_offset: 0,\n#      time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017, zone_abbr: \"UTC\"},\n#     %Johanna.Service.ExecutedNotOk{caller: {Test, :test, []}, message: \":-(\"}},\n#    {%DateTime{calendar: Calendar.ISO, day: 5, hour: 16,\n#      microsecond: {799580, 6}, minute: 12, month: 4, second: 28, std_offset: 0,\n#      time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017, zone_abbr: \"UTC\"},\n#     %Johanna.Service.ExecutedNotOk{caller: {Test, :test, []},\n#      message: \":-(\"}}], bag: [], caller: {Test, :test, []}, error: nil,\n#   message: nil, result: nil,\n#   time: %DateTime{calendar: Calendar.ISO, day: 5, hour: 13,\n#    microsecond: {245363, 6}, minute: 31, month: 4, second: 26, std_offset: 0,\n#    time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017, zone_abbr: \"UTC\"},\n#   type: {:retry, 48}}}\n\n# PAUSE FOR ≈100 SECONDS\nJohanna.Service.jobs\n#⇒ %{}\n\nJohanna.Spy.spy\n#⇒ [%Johanna.Message{attempts: [{%DateTime{calendar: Calendar.ISO, day: 5,\n#     hour: 16, microsecond: {885986, 6}, minute: 19, month: 4, second: 35,\n#     std_offset: 0, time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017,\n#     zone_abbr: \"UTC\"},\n#    %Johanna.Service.ExecutedNotOk{caller: {Test, :test, []}, message: \":-(\"}},\n#   {%DateTime{calendar: Calendar.ISO, day: 5, hour: 16,\n#     microsecond: {884950, 6}, minute: 18, month: 4, second: 47, std_offset: 0,\n#     time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017, zone_abbr: \"UTC\"},\n#    %Johanna.Service.ExecutedNotOk{caller: {Test, :test, []}, message: \":-(\"}},\n#   {%DateTime{calendar: Calendar.ISO, day: 5, hour: 16,\n#     microsecond: {883940, 6}, minute: 18, month: 4, second: 23, std_offset: 0,\n#     time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017, zone_abbr: \"UTC\"},\n#    %Johanna.Service.ExecutedNotOk{caller: {Test, :test, []}, message: \":-(\"}},\n#   {%DateTime{calendar: Calendar.ISO, day: 5, hour: 16,\n#     microsecond: {882947, 6}, minute: 18, month: 4, second: 11, std_offset: 0,\n#     time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017, zone_abbr: \"UTC\"},\n#    %Johanna.Service.ExecutedNotOk{caller: {Test, :test, []}, message: \":-(\"}},\n#   {%DateTime{calendar: Calendar.ISO, day: 5, hour: 16,\n#     microsecond: {882001, 6}, minute: 18, month: 4, second: 5, std_offset: 0,\n#     time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017, zone_abbr: \"UTC\"},\n#    %Johanna.Service.ExecutedNotOk{caller: {Test, :test, []}, message: \":-(\"}},\n#   {%DateTime{calendar: Calendar.ISO, day: 5, hour: 16,\n#     microsecond: {881281, 6}, minute: 18, month: 4, second: 2, std_offset: 0,\n#     time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017, zone_abbr: \"UTC\"},\n#    %Johanna.Service.ExecutedNotOk{caller: {Test, :test, []}, message: \":-(\"}}],\n#  bag: [], caller: {Test, :test, []}, error: nil, message: nil,\n#  result: {:ok, \":-)\"},\n#  time: %DateTime{calendar: Calendar.ISO, day: 5, hour: 13,\n#   microsecond: {245363, 6}, minute: 31, month: 4, second: 26, std_offset: 0,\n#   time_zone: \"Etc/UTC\", utc_offset: 0, year: 2017, zone_abbr: \"UTC\"},\n#  type: {:retry, 96}}]\n\n```\n\nUpon successful execution, the `Johanna.Message` is being moved to `Johanna.Spy`\nstore to be reported on demand. Note, that the result `result: {:ok, \":-)\"}` is\nalso stored in `Johanna.Spy` storage.\n\n### Changelog\n\n#### 0.2.0 — added `Johanna.Spy` and `Johanna.Service`\n\n\n### [Documentation](https://hexdocs.pm/johanna).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fam-kantox%2Fjohanna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fam-kantox%2Fjohanna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fam-kantox%2Fjohanna/lists"}