-module(automata@event@source). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/automata/event/source.gleam"). -export([new/2, with_name/2, schedule/1, file_system/1, manual/1, webhook/1, queue/1, signal/1, http/1, cloud_event/1, custom/2, kind_to_string/1]). -export_type([source_kind/0, source/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -type source_kind() :: schedule_source | file_system_source | manual_source | webhook_source | queue_source | signal_source | http_source | cloud_event_source | {custom_source, binary()}. -type source() :: {source, source_kind(), binary(), gleam@option:option(binary())}. -file("src/automata/event/source.gleam", 30). ?DOC( " Build a `Source` with no human-readable label. Use `with_name` to\n" " attach one if your transport/observability needs it.\n" ). -spec new(source_kind(), binary()) -> source(). new(Kind, Id) -> {source, Kind, Id, none}. -file("src/automata/event/source.gleam", 35). ?DOC(" Attach an optional human-readable label to a source.\n"). -spec with_name(source(), binary()) -> source(). with_name(Source, Name) -> {source, erlang:element(2, Source), erlang:element(3, Source), {some, Name}}. -file("src/automata/event/source.gleam", 40). ?DOC(" Shortcut for `new(ScheduleSource, id)`.\n"). -spec schedule(binary()) -> source(). schedule(Id) -> new(schedule_source, Id). -file("src/automata/event/source.gleam", 45). ?DOC(" Shortcut for `new(FileSystemSource, id)`.\n"). -spec file_system(binary()) -> source(). file_system(Id) -> new(file_system_source, Id). -file("src/automata/event/source.gleam", 50). ?DOC(" Shortcut for `new(ManualSource, id)`.\n"). -spec manual(binary()) -> source(). manual(Id) -> new(manual_source, Id). -file("src/automata/event/source.gleam", 55). ?DOC(" Shortcut for `new(WebhookSource, id)`.\n"). -spec webhook(binary()) -> source(). webhook(Id) -> new(webhook_source, Id). -file("src/automata/event/source.gleam", 60). ?DOC(" Shortcut for `new(QueueSource, id)`.\n"). -spec queue(binary()) -> source(). queue(Id) -> new(queue_source, Id). -file("src/automata/event/source.gleam", 65). ?DOC(" Shortcut for `new(SignalSource, id)`.\n"). -spec signal(binary()) -> source(). signal(Id) -> new(signal_source, Id). -file("src/automata/event/source.gleam", 70). ?DOC(" Shortcut for `new(HttpSource, id)`.\n"). -spec http(binary()) -> source(). http(Id) -> new(http_source, Id). -file("src/automata/event/source.gleam", 75). ?DOC(" Shortcut for `new(CloudEventSource, id)`.\n"). -spec cloud_event(binary()) -> source(). cloud_event(Id) -> new(cloud_event_source, Id). -file("src/automata/event/source.gleam", 81). ?DOC( " Shortcut for `new(CustomSource(kind), id)` — the escape hatch for\n" " ecosystem-external producers.\n" ). -spec custom(binary(), binary()) -> source(). custom(Kind, Id) -> new({custom_source, Kind}, Id). -file("src/automata/event/source.gleam", 87). ?DOC( " Stable string label for a `SourceKind`, used for routing tables,\n" " metrics, and structured logs.\n" ). -spec kind_to_string(source_kind()) -> binary(). kind_to_string(Kind) -> case Kind of schedule_source -> <<"schedule"/utf8>>; file_system_source -> <<"file_system"/utf8>>; manual_source -> <<"manual"/utf8>>; webhook_source -> <<"webhook"/utf8>>; queue_source -> <<"queue"/utf8>>; signal_source -> <<"signal"/utf8>>; http_source -> <<"http"/utf8>>; cloud_event_source -> <<"cloud_event"/utf8>>; {custom_source, Name} -> <<"custom:"/utf8, Name/binary>> end.