{"id":13508937,"url":"https://github.com/fishcakez/core","last_synced_at":"2025-08-18T03:39:51.350Z","repository":{"id":15341577,"uuid":"18072203","full_name":"fishcakez/core","owner":"fishcakez","description":"Library for selective receive OTP processes","archived":false,"fork":false,"pushed_at":"2014-09-14T21:55:50.000Z","size":439,"stargazers_count":43,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-15T15:04:44.847Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fishcakez.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":"2014-03-24T17:51:11.000Z","updated_at":"2024-12-11T21:57:27.000Z","dependencies_parsed_at":"2022-08-25T18:03:09.896Z","dependency_job_id":null,"html_url":"https://github.com/fishcakez/core","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/fishcakez/core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fishcakez%2Fcore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fishcakez%2Fcore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fishcakez%2Fcore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fishcakez%2Fcore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fishcakez","download_url":"https://codeload.github.com/fishcakez/core/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fishcakez%2Fcore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270940607,"owners_count":24671678,"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-08-18T02:00:08.743Z","response_time":89,"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:01:00.692Z","updated_at":"2025-08-18T03:39:51.325Z","avatar_url":"https://github.com/fishcakez.png","language":"Elixir","funding_links":[],"categories":["OTP"],"sub_categories":[],"readme":"# Core\nLibrary for implementing OTP processes natively in Elixir.\n\nProvides utility functions and macros to implement 100% OTP compliant\nprocesses with 100% compatibility with all Erlang/OTP modules and tools.\n\n# Installing\n```\ngit clone https://github.com/fishcakez/core.git\ncd core\nmix do deps.get, docs, compile\n```\n\n# Hello World\nStart a process that prints \"Hello World\" to `:stdio`.\n```elixir\ndefmodule HelloWorld do\n\n  use Core\n\n  def start_link(), do: Core.start_link(__MODULE__, nil)\n\n  def init(_parent, _debug, _args) do\n    IO.puts(\"Hello World\")\n    # Core.init_ack/0 will cause start_link/0 to return { :ok, self() }. If this\n    # function is never called start_link will block until this process exits.\n    Core.init_ack()\n    exit(:normal)\n  end\n\nend\n```\n\n# Features\n* Asynchronous and synchronous process initiation (with name registration).\n* Automatic logging of un-rescued exceptions.\n* System calls that work with any OTP compliant process.\n* Receive macro to handle system messages.\n* Supports progressive enhancement of OTP features: system message\n  automatically handled until you want to change the default behaviour.\n\n# Basic Ping Server\nStarts a process that can be pinged.\n```elixir\ndefmodule PingPong do\n\n  use Core\n\n  @spec ping(Core.t) :: :pong\n  def ping(process), do: Core.call(process, __MODULE__, :ping, 5000)\n\n  @spec count(Core.t) :: non_neg_integer\n  def count(process), do: Core.call(process, __MODULE__, :count, 5000)\n\n  @spec close(Core.t) :: :ok\n  def close(process), do: Core.call(process, __MODULE__, :close, 5000)\n\n  @spec start_link() :: { :ok, pid }\n  def start_link() do\n    Core.start_link(__MODULE__, nil)\n  end\n\n  # Core api\n\n  def init(_parent, _debug, _args) do\n    Core.init_ack()\n    loop(0)\n  end\n\n  ## Internal\n\n  defp loop(count) do\n    receive do\n      { __MODULE__, from, :ping } -\u003e\n        Core.reply(from, :pong)\n        loop(count + 1)\n      { __MODULE__, from, :count } -\u003e\n        Core.reply(from, count)\n        loop(count)\n      { __MODULE__, from, :close } -\u003e\n        Core.reply(from, :ok)\n        terminate(:normal)\n    end\n  end\n\n  defp terminate(reason) do\n    exit(reason)\n  end\n\nend\n```\n\n# Advanced Ping Server\nStarts a process that can be pinged, live debugged and live code\nupgraded.\n\nFor example `Core.Sys.set_state(pid, 0)` will reset the `count` to `0`.\n```elixir\n\ndefmodule PingPong do\n\n  use Core.Sys\n\n  @spec ping(Core.t) :: :pong\n  def ping(process), do: Core.call(process, __MODULE__, :ping, 5000)\n\n  @spec count(Core.t) :: non_neg_integer\n  def count(process), do: Core.call(process, __MODULE__, :count, 5000)\n\n  @spec close(Core.t) :: :ok\n  def close(process), do: Core.call(process, __MODULE__, :close, 5000)\n\n  # die/1 will print alot of information because the exit reason is abnormal.\n  @spec die(Core.t) :: :ok\n  def die(process), do: Core.call(process, __MODULE__, :die, 5000)\n\n  @spec start_link() :: { :ok, pid }\n  def start_link() do\n    Core.start_link(nil, __MODULE__, nil,\n      [{ :debug, [{ :log, 10 }, { :stats, true }] }])\n  end\n\n  ## Core api\n\n  def init(parent, debug, _args) do\n    Core.init_ack()\n    loop(0, parent, debug)\n  end\n\n  ## Core.Sys (minimal) api\n\n  def system_continue(count, parent, debug), do: loop(count, parent, debug)\n\n  def system_terminate(count, parent, debug, reason) do\n    terminate(count, parent, debug, reason)\n  end\n\n  ## Internal\n\n  defp loop(count, parent, debug) do\n    Core.Sys.receive(__MODULE__, count, parent, debug) do\n      { __MODULE__, from, :ping } -\u003e\n        # It is not required to record events using `Core.Debug.event/1` but is\n        # a useful debug feature that is compiled to a no-op in production.\n        debug = Core.Debug.event(debug, { :in, :ping, elem(from, 0) })\n        Core.reply(from, :pong)\n        debug = Core.Debug.event(debug, { :out, :pong, elem(from, 0) })\n        count = count + 1\n        debug = Core.Debug.event(debug, { :count, count })\n        loop(count, parent, debug)\n      { __MODULE__, from, :count } -\u003e\n        debug = Core.Debug.event(debug, { :in, :count, elem(from, 0) })\n        Core.reply(from, count)\n        debug = Core.Debug.event(debug, { :out, count, elem(from, 0) })\n        loop(count, parent, debug)\n      { __MODULE__, from, :close } -\u003e\n        debug = Core.Debug.event(debug, { :in, :close, elem(from, 0) })\n        Core.reply(from, :ok)\n        debug = Core.Debug.event(debug, { :out, :ok, elem(from, 0)  })\n        terminate(count, parent, debug, :normal)\n      { __MODULE__, from, :die } -\u003e\n        debug = Core.Debug.event(debug, { :in, :die, elem(from, 0) })\n        Core.reply(from, :ok)\n        debug = Core.Debug.event(debug, { :out, :ok, elem(from, 0)  })\n        terminate(count, parent, debug, :die)\n    end\n  end\n\n  defp terminate(count, parent, debug, reason) do\n    event = { :EXIT, reason }\n    debug = Core.Debug.event(debug, event)\n    Core.stop(__MODULE__, count, parent, debug, reason, event)\n  end\n\nend\n```\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffishcakez%2Fcore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffishcakez%2Fcore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffishcakez%2Fcore/lists"}