From fb6f9f6888e8780b2251c111cb7f07f3ebe4be60 Mon Sep 17 00:00:00 2001 From: Phil Chen <06fahchen@gmail.com> Date: Sat, 17 Jun 2023 10:35:45 +0800 Subject: [PATCH] fix: storage or registry can be nil --- lib/workflow_metal/application/supervisor.ex | 16 ++++++++++------ lib/workflow_metal/registration/adapter.ex | 2 +- lib/workflow_metal/storage/adapter.ex | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/workflow_metal/application/supervisor.ex b/lib/workflow_metal/application/supervisor.ex index fb981bd..1ac76d1 100644 --- a/lib/workflow_metal/application/supervisor.ex +++ b/lib/workflow_metal/application/supervisor.ex @@ -25,12 +25,16 @@ defmodule WorkflowMetal.Application.Supervisor do config_child_spec = config_child_spec(application, config) - children = [ - config_child_spec, - registry_child_spec, - storage_child_spec, - {WorkflowMetal.Application.WorkflowsSupervisor, application} - ] + children = + Enum.reject( + [ + config_child_spec, + registry_child_spec, + storage_child_spec, + {WorkflowMetal.Application.WorkflowsSupervisor, application} + ], + &is_nil/1 + ) Supervisor.init(children, strategy: :one_for_one) end diff --git a/lib/workflow_metal/registration/adapter.ex b/lib/workflow_metal/registration/adapter.ex index 12294a4..82cd837 100644 --- a/lib/workflow_metal/registration/adapter.ex +++ b/lib/workflow_metal/registration/adapter.ex @@ -21,7 +21,7 @@ defmodule WorkflowMetal.Registration.Adapter do Return a supervisor spec for the registry """ @callback child_spec(application, config) :: - {:ok, :supervisor.child_spec() | {module, term} | module, adapter_meta} + {:ok, :supervisor.child_spec() | {module, term} | module | nil, adapter_meta} @doc """ Return a `:via` tuple to route a message to a process by its registered name diff --git a/lib/workflow_metal/storage/adapter.ex b/lib/workflow_metal/storage/adapter.ex index 1a23181..6f46782 100644 --- a/lib/workflow_metal/storage/adapter.ex +++ b/lib/workflow_metal/storage/adapter.ex @@ -13,7 +13,7 @@ defmodule WorkflowMetal.Storage.Adapter do Return a child spec for the storage """ @callback child_spec(application, config) :: - {:ok, :supervisor.child_spec() | {module, term} | module, adapter_meta} + {:ok, :supervisor.child_spec() | {module, term} | module | nil, adapter_meta} # Workflow