{"id":13507133,"url":"https://github.com/tattdcodemonkey/mon_handler","last_synced_at":"2025-09-12T15:51:14.558Z","repository":{"id":32311648,"uuid":"35886745","full_name":"TattdCodeMonkey/mon_handler","owner":"TattdCodeMonkey","description":"Elixir GenServer used to monitor a GenEvent event handler  ","archived":false,"fork":false,"pushed_at":"2017-09-10T04:21:05.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-29T22:11:51.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TattdCodeMonkey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-19T14:18:56.000Z","updated_at":"2017-09-10T04:09:15.000Z","dependencies_parsed_at":"2022-08-26T03:32:54.430Z","dependency_job_id":null,"html_url":"https://github.com/TattdCodeMonkey/mon_handler","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/TattdCodeMonkey/mon_handler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TattdCodeMonkey%2Fmon_handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TattdCodeMonkey%2Fmon_handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TattdCodeMonkey%2Fmon_handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TattdCodeMonkey%2Fmon_handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TattdCodeMonkey","download_url":"https://codeload.github.com/TattdCodeMonkey/mon_handler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TattdCodeMonkey%2Fmon_handler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274832159,"owners_count":25358014,"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-09-12T02:00:09.324Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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-01T02:00:24.767Z","updated_at":"2025-09-12T15:51:14.508Z","avatar_url":"https://github.com/TattdCodeMonkey.png","language":"Elixir","funding_links":[],"categories":["Actors"],"sub_categories":[],"readme":"MonHandler - Monitored Event Handler\n==========\n[![Hex version](https://img.shields.io/hexpm/v/mon_handler.svg \"Hex\nversion\")](https://hex.pm/packages/mon_handler)\n\nThis is a minimal `GenServer` module that is used to monitor an event handler.\n\nTo use simply call `add_mon_handler` or `start_link` with the `GenEvent` event manager, event handler and args for your event handler. Optionally you can also pass arguments for the `MonHandler` `GenServer`.\n\n`MonHanlder` will handle messages from the event manager if the event handler terminates. For normal terminations `MonHandler` will stop. For terminations due to errors `MonHandler` will re-add the event handler to the event manager.\n\n### Use Cases\n\nBasic:\n```elixir\niex(x)\u003e {:ok, manager} = GenEvent.start_link\n{:ok, #PID\u003cX.Y.Z\u003e}\niex(x)\u003e {:ok, mon_han} = MonHandler.start_link(manager, YourEventHandler, event_handler_args, gen_server_args)\n{:ok, #PID\u003cX.Y.Z\u003e}\niex(x)\u003e GenEvent.notify(manager, {:your_event, \"some data\"})\n:ok\niex(x)\u003e MonHandler.remove_handler(mon_han)\n:ok  \n```\nStarting with a supervisor\n```elixir\nmon_handler_config = MonHandler.get_config(manager, YourEventHandler, event_handler_args)\nsupervise([worker(MonHandler, [mon_handler_config, []])], [strategy: :one_for_one])\n```\n\nIf you want to use MonHandler for multiple handlers within a single app you will need to give each an `id` when adding them to the supervisor.\n```elixir\nsupervise(\n  [\n    worker(\n      MonHandler,\n      [\n        MonHandler.get_config(:manager_one, YourEventHandler, []),\n        []\n      ],\n      [id: :first_handler]\n    ),\n    worker(\n      MonHandler,\n      [\n        MonHandler.get_config(:manager_two, YourSecondEventHandler, []),\n        []\n      ],\n      [id: :second_handler]\n    )\n  ],\n  [strategy: :one_for_one]\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftattdcodemonkey%2Fmon_handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftattdcodemonkey%2Fmon_handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftattdcodemonkey%2Fmon_handler/lists"}