### EctoWatch Setup in application.ex Source: https://hexdocs.pm/ecto_watch/getting-started Demonstrates how to add EctoWatch to your application's supervision tree and configure schema watchers. This setup includes specifying the Ecto repository and PubSub adapter, and defining which schemas and events to watch. ```elixir alias MyApp.Accounts.User alias MyApp.Accounts.Package children = [ MyApp.Repo, MyApp.PubSub, {EctoWatch, repo: MyApp.Repo, pub_sub: MyApp.PubSub, watchers: [ {User, :inserted}, {User, :updated}, {User, :deleted}, {Package, :inserted}, {Package, :updated} ] } ] ``` -------------------------------- ### Ecto Watch Application Supervisor Setup Source: https://hexdocs.pm/ecto_watch/testing This Elixir code defines the application's supervisor, including starting Ecto Watch with specified repository and pub/sub configurations, and a custom `MyApp.UpdateCounter` module to watch for `Records.Record` updates. ```elixir defmodule MyApp.Application do use Application def start(_type, _args) do children = [ {EctoWatch, repo: MyApp.Repo, pub_sub: MyApp.PubSub, watchers: [{Records.Record, :updated}]}, # Ensure that your module is started after EctoWatch {MyApp.UpdateCounter, []} ] opts = [strategy: :one_for_one, name: MyApp.Supervisor] Supervisor.start_link(children, opts) end end ``` -------------------------------- ### EctoWatch Setup and Subscription Source: https://hexdocs.pm/ecto_watch/getting-additional-values Demonstrates how to configure EctoWatch with a repository and PubSub, and how to subscribe to specific events like `:deleted` comments. ```elixir setup{EctoWatch,repo:MyApp.Repo,pub_sub:MyApp.PubSub,watchers:[# ...{Comment,:deleted,extra_columns:[:post_id]}]} ``` ```elixir EctoWatch.subscribe({Comment,:deleted}) ``` -------------------------------- ### EctoWatch Functions Source: https://hexdocs.pm/ecto_watch/upgrading-versions Provides functions for interacting with EctoWatch, including starting, subscribing, and unsubscribing from watchers. ```APIDOC EctoWatch: child_spec(init_arg) Generates a child specification for EctoWatch. details(watcher_identifier) Retrieves details about a watcher. init(options) Initializes EctoWatch with the given options. start_link(opts) Starts EctoWatch as a supervised process. subscribe(watcher_identifier, id \ nil) Subscribes to changes for a given watcher identifier. subscribe(schema_mod_or_label, update_type, id) Subscribes to changes for a schema module or label, specifying the update type and an ID. unsubscribe(watcher_identifier, id \ nil) Unsubscribes from changes for a given watcher identifier. ``` -------------------------------- ### EctoWatch Core Functions Source: https://hexdocs.pm/ecto_watch/EctoWatch Provides core functionalities for interacting with EctoWatch, including starting the service, subscribing to changes, and unsubscribing. ```APIDOC EctoWatch: child_spec(init_arg) - Creates a child specification for the EctoWatch supervisor. - Parameters: - init_arg: The initialization argument for the supervisor. details(watcher_identifier) - Retrieves details about a specific watcher. - Parameters: - watcher_identifier: The identifier of the watcher. - Returns: Details of the watcher. init(options) - Initializes the EctoWatch process with given options. - Parameters: - options: A map of options for initialization. start_link(opts) - Starts the EctoWatch process and links it to the current process. - Parameters: - opts: Options for starting the process. subscribe(watcher_identifier, id \ nil) - Subscribes to changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher to subscribe to. - id: An optional identifier for the subscription. - Returns: The subscription details. subscribe(schema_mod_or_label, update_type, id) - Subscribes to changes for a specific schema module or label. - Parameters: - schema_mod_or_label: The schema module or label to monitor. - update_type: The type of update to subscribe to (e.g., :insert, :update, :delete). - id: An identifier for the subscription. - Returns: The subscription details. unsubscribe(watcher_identifier, id \ nil) - Unsubscribes from changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher to unsubscribe from. - id: The optional identifier of the subscription to remove. - Returns: The result of the unsubscribe operation. ``` -------------------------------- ### EctoWatch Functions Source: https://hexdocs.pm/ecto_watch/EctoWatch Provides core functions for interacting with EctoWatch, including starting the module under a supervisor, retrieving watcher details, and managing subscriptions. ```APIDOC child_spec(init_arg) - Returns a specification to start this module under a supervisor. - Related to: Supervisor.init/1 details(watcher_identifier) - Returns details about a watcher for reflection purposes. - Parameters: - watcher_identifier: An atom or a tuple of {atom(), atom()} representing the watcher. - Returns: - A map containing watcher details including repo_mod, schema_definition, function_name, trigger_name, and notify_channel. - Example: iex> EctoWatch.subscribe({Comment,:updated}) iex> EctoWatch.subscribe(:comment_updated_custom) init(options) - Callback implementation for Supervisor.init/1. start_link(opts) - Starts the EctoWatch process. subscribe(watcher_identifier, id \ nil) - Subscribe to notifications from watchers. - Parameters: - watcher_identifier: The watcher to subscribe to. - id: An optional identifier for the subscription. subscribe(schema_mod_or_label, update_type, id) - Deprecated: Subscribe to notifications from watchers. unsubscribe(watcher_identifier, id \ nil) - Unsubscribe from notifications from watchers that you previously subscribed to. - Parameters: - watcher_identifier: The watcher to unsubscribe from. - id: The optional identifier of the subscription to unsubscribe. ``` -------------------------------- ### EctoWatch Functions Source: https://hexdocs.pm/ecto_watch/watching-without-a-schema Provides functions for managing Ecto watchers, including starting, subscribing, and unsubscribing. ```APIDOC EctoWatch: child_spec(init_arg) - Creates a child specification for the EctoWatch supervisor. details(watcher_identifier) - Retrieves details about a specific watcher. init(options) - Initializes the EctoWatch system with given options. start_link(opts) - Starts the EctoWatch supervisor and links it to the current process. subscribe(watcher_identifier, id \ nil) - Subscribes to changes for a given watcher identifier. subscribe(schema_mod_or_label, update_type, id) - Subscribes to changes for a schema module or label, specifying the update type and an optional ID. unsubscribe(watcher_identifier, id \ nil) - Unsubscribes from changes for a given watcher identifier. ``` -------------------------------- ### EctoWatch Functions Source: https://hexdocs.pm/ecto_watch/tracking-columns-and-using-labels Provides functions for managing database watchers, including starting, subscribing, and unsubscribing from schema changes. ```APIDOC EctoWatch: child_spec(init_arg) Generates a child specification for starting EctoWatch as a supervisor. details(watcher_identifier) Retrieves details about a specific watcher. init(options) Initializes the EctoWatch supervisor with given options. start_link(opts) Starts the EctoWatch supervisor and links it to the current process. subscribe(watcher_identifier, id \ nil) Subscribes to changes for a given watcher identifier. subscribe(schema_mod_or_label, update_type, id) Subscribes to specific update types for a schema or label. unsubscribe(watcher_identifier, id \ nil) Unsubscribes from changes for a given watcher identifier. ``` -------------------------------- ### EctoWatch.WatcherServer API Documentation Source: https://hexdocs.pm/ecto_watch/EctoWatch.WatcherServer Provides API documentation for the EctoWatch.WatcherServer module. This includes functions for starting the server, managing subscriptions, and retrieving server details. It details function signatures, parameters, and their purposes. ```APIDOC EctoWatch.WatcherServer: child_spec(init_arg) - Returns a specification to start this module under a supervisor. - See: `Supervisor` details(pid) - Retrieves details about the watcher server. name(watcher_options) - Sets or retrieves the name for the watcher. pub_sub_subscription_details(identifier, identifier_value) - Provides details for a pub/sub subscription. start_link(arg) - Starts the watcher server process. topics(update_type, unique_label, returned_values, schema_definition) - Manages or retrieves information about topics for watching. ``` -------------------------------- ### EctoWatch Module Functions Source: https://hexdocs.pm/ecto_watch/getting-started Provides functions for interacting with EctoWatch, including starting the supervision tree, subscribing to schema changes, and retrieving watcher details. ```APIDOC EctoWatch: child_spec(init_arg) - Creates a child specification for the EctoWatch supervisor. - Parameters: - init_arg: Arguments for initializing the supervisor. details(watcher_identifier) - Retrieves details about a specific watcher. - Parameters: - watcher_identifier: The identifier of the watcher. - Returns: Details of the watcher. init(options) - Initializes the EctoWatch module with given options. - Parameters: - options: Configuration options for EctoWatch. start_link(opts) - Starts the EctoWatch process along with its supervisor. - Parameters: - opts: Options for starting the process. - Returns: {:ok, pid} or {:error, reason}. subscribe(watcher_identifier, id \ nil) - Subscribes to changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher. - id: An optional identifier for the subscription. - Returns: The subscription identifier. subscribe(schema_mod_or_label, update_type, id) - Subscribes to schema changes based on schema module or label and update type. - Parameters: - schema_mod_or_label: The Ecto schema module or a custom label. - update_type: The type of update to subscribe to (e.g., :insert, :update, :delete). - id: An identifier for the subscription. - Returns: The subscription identifier. unsubscribe(watcher_identifier, id \ nil) - Unsubscribes from changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher. - id: The subscription identifier to unsubscribe. - Returns: :ok or {:error, reason}. ``` -------------------------------- ### EctoWatch API Reference Source: https://hexdocs.pm/ecto_watch/potential-todos Provides functions for interacting with EctoWatch, including starting and managing watchers, subscribing to changes, and retrieving details. ```APIDOC EctoWatch: child_spec(init_arg) - Creates a child specification for the EctoWatch supervisor. - Parameters: - init_arg: The initialization argument for the supervisor. details(watcher_identifier) - Retrieves details about a specific watcher. - Parameters: - watcher_identifier: The identifier of the watcher. - Returns: Details of the watcher. init(options) - Initializes the EctoWatch module with given options. - Parameters: - options: A map of configuration options. start_link(opts) - Starts the EctoWatch supervisor and its children. - Parameters: - opts: A list of options for starting the supervisor. - Returns: {:ok, pid} or {:error, reason}. subscribe(watcher_identifier, id \\ nil) - Subscribes to changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher to subscribe to. - id: An optional identifier for the subscription. - Returns: The subscription identifier. subscribe(schema_mod_or_label, update_type, id) - Subscribes to changes based on schema module or label and update type. - Parameters: - schema_mod_or_label: The Ecto schema module or a custom label. - update_type: The type of update to subscribe to (e.g., :insert, :update, :delete). - id: An optional identifier for the subscription. - Returns: The subscription identifier. unsubscribe(watcher_identifier, id \\ nil) - Unsubscribes from changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher to unsubscribe from. - id: The subscription identifier to unsubscribe. - Returns: :ok or {:error, reason}. ``` -------------------------------- ### EctoWatch.WatcherSupervisor API Documentation Source: https://hexdocs.pm/ecto_watch/EctoWatch.WatcherSupervisor Provides the API documentation for the EctoWatch.WatcherSupervisor module. This includes functions for starting the supervisor, initializing it, and retrieving watcher details. It details the purpose, parameters, and return values for each function, along with links to source code and related Elixir documentation. ```APIDOC EctoWatch.WatcherSupervisor: child_spec(init_arg) Returns a specification to start this module under a supervisor. See: Supervisor.init/1 init(options) Callback implementation for Supervisor.init/1. start_link(options) Starts the watcher supervisor. watcher_details() Returns details about the watchers managed by this supervisor. ``` -------------------------------- ### EctoWatch Functions Source: https://hexdocs.pm/ecto_watch/notes Provides functions for managing Ecto schema watchers, including starting, subscribing, and unsubscribing. ```APIDOC EctoWatch: child_spec(init_arg) Creates a child specification for the EctoWatch supervisor. details(watcher_identifier) Retrieves details about a specific watcher. init(options) Initializes the EctoWatch supervisor with given options. start_link(opts) Starts the EctoWatch supervisor and links it to the current process. subscribe(watcher_identifier, id \ nil) Subscribes to changes for a given watcher identifier. subscribe(schema_mod_or_label, update_type, id) Subscribes to changes for a schema module or label, specifying the update type and an optional ID. unsubscribe(watcher_identifier, id \ nil) Unsubscribes from changes for a given watcher identifier. ``` -------------------------------- ### EctoWatch Module Functions Source: https://hexdocs.pm/ecto_watch/testing Provides functions for interacting with EctoWatch, including starting the supervision tree, subscribing to schema changes, and retrieving watcher details. ```APIDOC EctoWatch: child_spec(init_arg) - Creates a child specification for the EctoWatch supervisor. - Parameters: - init_arg: Arguments for initializing the supervisor. details(watcher_identifier) - Retrieves details about a specific watcher. - Parameters: - watcher_identifier: The identifier of the watcher. - Returns: Details of the watcher. init(options) - Initializes the EctoWatch module with given options. - Parameters: - options: Configuration options for EctoWatch. start_link(opts) - Starts the EctoWatch process along with its supervisor. - Parameters: - opts: Options for starting the process. - Returns: {:ok, pid} or {:error, reason}. subscribe(watcher_identifier, id \ nil) - Subscribes to changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher. - id: An optional identifier for the subscription. - Returns: The subscription identifier. subscribe(schema_mod_or_label, update_type, id) - Subscribes to schema changes based on schema module or label and update type. - Parameters: - schema_mod_or_label: The Ecto schema module or a custom label. - update_type: The type of update to subscribe to (e.g., :insert, :update, :delete). - id: An identifier for the subscription. - Returns: The subscription identifier. unsubscribe(watcher_identifier, id \ nil) - Unsubscribes from changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher. - id: The subscription identifier to unsubscribe. - Returns: :ok or {:error, reason}. ``` -------------------------------- ### EctoWatch Functions Source: https://hexdocs.pm/ecto_watch/changelog Provides functions for interacting with EctoWatch, including starting the supervision tree, subscribing to schema changes, and retrieving watcher details. ```elixir child_spec(init_arg) --- Returns a child specification for EctoWatch. details(watcher_identifier) --- Returns details about a specific watcher. init(options) --- Initializes EctoWatch with the given options. start_link(opts) --- Starts EctoWatch and its associated processes. subscribe(watcher_identifier, id \ nil) --- Subscribes to changes for a given watcher identifier. subscribe(schema_mod_or_label, update_type, id) --- Subscribes to changes for a schema module or label, specifying the update type and an optional ID. unsubscribe(watcher_identifier, id \ nil) --- Unsubscribes from changes for a given watcher identifier. ``` -------------------------------- ### EctoWatch.WatcherSupervisor Functions Source: https://hexdocs.pm/ecto_watch/tracking-columns-and-using-labels Manages the lifecycle of watcher processes, providing functions to start and manage them. ```APIDOC EctoWatch.WatcherSupervisor: child_spec(init_arg) Generates a child specification for the WatcherSupervisor. init(options) Initializes the WatcherSupervisor with provided options. start_link(options) Starts the WatcherSupervisor and links it to the current process. watcher_details() Retrieves details about all managed watchers. ``` -------------------------------- ### EctoWatch Functions Source: https://hexdocs.pm/ecto_watch/index Provides functions for interacting with Ecto database watchers, including starting, subscribing, and unsubscribing from changes. ```APIDOC EctoWatch: child_spec(init_arg) - Creates a child specification for EctoWatch. - Parameters: - init_arg: The initialization argument for the EctoWatch process. details(watcher_identifier) - Retrieves details about a specific watcher. - Parameters: - watcher_identifier: The identifier of the watcher. - Returns: Details of the watcher. init(options) - Initializes the EctoWatch process with the given options. - Parameters: - options: A map of configuration options. start_link(opts) - Starts the EctoWatch process and links it to the calling process. - Parameters: - opts: Options for starting the process. subscribe(watcher_identifier, id \\ nil) - Subscribes to changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher. - id: An optional identifier for the subscription. subscribe(schema_mod_or_label, update_type, id) - Subscribes to changes for a specific schema module or label and update type. - Parameters: - schema_mod_or_label: The Ecto schema module or a custom label. - update_type: The type of update to subscribe to (e.g., :insert, :update, :delete). - id: An identifier for the subscription. unsubscribe(watcher_identifier, id \\ nil) - Unsubscribes from changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher. - id: The identifier of the subscription to unsubscribe. ``` -------------------------------- ### EctoWatch Functions Source: https://hexdocs.pm/ecto_watch/api-reference Provides functions for interacting with Ecto database watchers, including starting, subscribing, and unsubscribing from changes. ```APIDOC EctoWatch: child_spec(init_arg) - Creates a child specification for EctoWatch. - Parameters: - init_arg: The initialization argument for the EctoWatch process. details(watcher_identifier) - Retrieves details about a specific watcher. - Parameters: - watcher_identifier: The identifier of the watcher. - Returns: Details of the watcher. init(options) - Initializes the EctoWatch process with the given options. - Parameters: - options: A map of configuration options. start_link(opts) - Starts the EctoWatch process and links it to the calling process. - Parameters: - opts: Options for starting the process. subscribe(watcher_identifier, id \\ nil) - Subscribes to changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher. - id: An optional identifier for the subscription. subscribe(schema_mod_or_label, update_type, id) - Subscribes to changes for a specific schema module or label and update type. - Parameters: - schema_mod_or_label: The Ecto schema module or a custom label. - update_type: The type of update to subscribe to (e.g., :insert, :update, :delete). - id: An identifier for the subscription. unsubscribe(watcher_identifier, id \\ nil) - Unsubscribes from changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher. - id: The identifier of the subscription to unsubscribe. ``` -------------------------------- ### EctoWatch Functions Source: https://hexdocs.pm/ecto_watch/getting-additional-values Provides functions for interacting with EctoWatch, including starting the supervision tree, subscribing to schema changes, and retrieving watcher details. ```APIDOC EctoWatch: child_spec(init_arg) Generates a child specification for EctoWatch. details(watcher_identifier) Retrieves details about a specific watcher. init(options) Initializes EctoWatch with the given options. start_link(opts) Starts EctoWatch and links it to the calling process. subscribe(watcher_identifier, id \ nil) Subscribes to changes for a given watcher identifier. subscribe(schema_mod_or_label, update_type, id) Subscribes to changes for a schema module or label, specifying the update type and an optional ID. unsubscribe(watcher_identifier, id \ nil) Unsubscribes from changes for a given watcher identifier. ``` -------------------------------- ### EctoWatch Module Functions Source: https://hexdocs.pm/ecto_watch/unsubscribing Provides functions for interacting with EctoWatch, including starting the supervision tree, subscribing to schema changes, and retrieving watcher details. ```APIDOC EctoWatch: child_spec(init_arg) - Creates a child specification for the EctoWatch supervisor. - Parameters: - init_arg: Arguments for initializing the supervisor. details(watcher_identifier) - Retrieves details about a specific watcher. - Parameters: - watcher_identifier: The identifier of the watcher. - Returns: Details of the watcher. init(options) - Initializes the EctoWatch module with given options. - Parameters: - options: Configuration options for EctoWatch. start_link(opts) - Starts the EctoWatch process along with its supervisor. - Parameters: - opts: Options for starting the process. - Returns: {:ok, pid} or {:error, reason}. subscribe(watcher_identifier, id \ nil) - Subscribes to changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher. - id: An optional identifier for the subscription. - Returns: The subscription identifier. subscribe(schema_mod_or_label, update_type, id) - Subscribes to schema changes based on schema module or label and update type. - Parameters: - schema_mod_or_label: The Ecto schema module or a custom label. - update_type: The type of update to subscribe to (e.g., :insert, :update, :delete). - id: An identifier for the subscription. - Returns: The subscription identifier. unsubscribe(watcher_identifier, id \ nil) - Unsubscribes from changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher. - id: The subscription identifier to unsubscribe. - Returns: :ok or {:error, reason}. ``` -------------------------------- ### EctoWatch API Reference Source: https://hexdocs.pm/ecto_watch/changelog This section details the API reference for EctoWatch, including modules and their functionalities. It serves as a comprehensive guide to using the library's features programmatically. ```APIDOC API Reference: - Modules: https://hexdocs.pm/ecto_watch/api-reference.html#modules Guides: - Introduction - Getting Started: https://hexdocs.pm/ecto_watch/getting-started.html - Tracking columns and using labels: https://hexdocs.pm/ecto_watch/tracking-columns-and-using-labels.html - Getting additional values: https://hexdocs.pm/ecto_watch/getting-additional-values.html - Watching without a schema: https://hexdocs.pm/ecto_watch/watching-without-a-schema.html - Unsubscribing: https://hexdocs.pm/ecto_watch/unsubscribing.html - Trigger Length Errors: https://hexdocs.pm/ecto_watch/trigger-length-errors.html - Debugging: https://hexdocs.pm/ecto_watch/debugging.html - Testing: https://hexdocs.pm/ecto_watch/testing.html - Notes: https://hexdocs.pm/ecto_watch/notes.html How-To's: - Upgrading Versions: https://hexdocs.pm/ecto_watch/upgrading-versions.html - Upgrading to 0.6.0: https://hexdocs.pm/ecto_watch/upgrading-versions.html#upgrading-to-0-6-0 - Upgrading to 0.8.0: https://hexdocs.pm/ecto_watch/upgrading-versions.html#upgrading-to-0-8-0 Changelog: - [0.13.3] - 2024-06-19: https://hexdocs.pm/ecto_watch/changelog.html#0-13-3-2024-06-19 - [0.13.2] - 2024-05-22: https://hexdocs.pm/ecto_watch/changelog.html#0-13-2-2024-05-22 - [0.13.1] - 2024-04-04: https://hexdocs.pm/ecto_watch/changelog.html#0-13-1-2024-04-04 - [0.13.0] - 2024-04-04: https://hexdocs.pm/ecto_watch/changelog.html#0-13-0-2024-04-04 - [0.12.6] - 2024-04-01: https://hexdocs.pm/ecto_watch/changelog.html#0-12-6-2024-04-01 - [0.12.5] - 2024-02-14: https://hexdocs.pm/ecto_watch/changelog.html#0-12-5-2024-02-14 - [0.12.4] - 2024-02-13: https://hexdocs.pm/ecto_watch/changelog.html#0-12-4-2024-02-13 - [0.12.3] - 2024-02-13: https://hexdocs.pm/ecto_watch/changelog.html#0-12-3-2024-02-13 - [0.12.2] - 2024-12-16: https://hexdocs.pm/ecto_watch/changelog.html#0-12-2-2024-12-16 - [0.12.1] - 2024-10-17: https://hexdocs.pm/ecto_watch/changelog.html#0-12-1-2024-10-17 - [0.12.0] - 2024-10-17: https://hexdocs.pm/ecto_watch/changelog.html#0-12-0-2024-10-17 - [0.11.2] - 2024-10-07: https://hexdocs.pm/ecto_watch/changelog.html#0-11-2-2024-10-07 - [0.11.1] - 2024-08-22: https://hexdocs.pm/ecto_watch/changelog.html#0-11-1-2024-08-22 - [0.11.0] - 2024-08-19: https://hexdocs.pm/ecto_watch/changelog.html#0-11-0-2024-08-19 - [0.10.0] - 2024-08-16: https://hexdocs.pm/ecto_watch/changelog.html#0-10-0-2024-08-16 - [0.9.11] - 2024-08-12: https://hexdocs.pm/ecto_watch/changelog.html#0-9-11-2024-08-12 - [0.9.10] - 2024-08-12: https://hexdocs.pm/ecto_watch/changelog.html#0-9-10-2024-08-12 - [0.9.9] - 2024-08-10: https://hexdocs.pm/ecto_watch/changelog.html#0-9-9-2024-08-10 - [0.9.8] - 2024-08-10: https://hexdocs.pm/ecto_watch/changelog.html#0-9-8-2024-08-10 - [0.9.7] - 2024-08-10: https://hexdocs.pm/ecto_watch/changelog.html#0-9-7-2024-08-10 - [0.9.6] - 2024-08-10: https://hexdocs.pm/ecto_watch/changelog.html#0-9-6-2024-08-10 - [0.9.5] - 2024-08-08: https://hexdocs.pm/ecto_watch/changelog.html#0-9-5-2024-08-08 - [0.9.4] - 2024-08-08: https://hexdocs.pm/ecto_watch/changelog.html#0-9-4-2024-08-08 - [0.9.3] - 2024-08-08: https://hexdocs.pm/ecto_watch/changelog.html#0-9-3-2024-08-08 - [0.9.2] - 2024-08-08: https://hexdocs.pm/ecto_watch/changelog.html#0-9-2-2024-08-08 - [0.9.1] - 2024-08-08: https://hexdocs.pm/ecto_watch/changelog.html#0-9-1-2024-08-08 - [0.9.0] - 2024-08-07: https://hexdocs.pm/ecto_watch/changelog.html#0-9-0-2024-08-07 - [0.8.1] - 2024-08-07: https://hexdocs.pm/ecto_watch/changelog.html#0-8-1-2024-08-07 - [0.8.0] - 2024-08-07: https://hexdocs.pm/ecto_watch/changelog.html#0-8-0-2024-08-07 - [0.7.0] - 2024-07-31: https://hexdocs.pm/ecto_watch/changelog.html#0-7-0-2024-07-31 - [0.6.0] - 2024-07-30: https://hexdocs.pm/ecto_watch/changelog.html#0-6-0-2024-07-30 - [0.5.4] - 2024-07-18: https://hexdocs.pm/ecto_watch/changelog.html#0-5-4-2024-07-18 - [0.5.3] - 2024-07-12: https://hexdocs.pm/ecto_watch/changelog.html#0-5-3-2024-07-12 - [0.5.1] - 2024-07-02: https://hexdocs.pm/ecto_watch/changelog.html#0-5-1-2024-07-02 - [0.5.0] - 2024-07-02: https://hexdocs.pm/ecto_watch/changelog.html#0-5-0-2024-07-02 ``` -------------------------------- ### EctoWatch API Reference Source: https://hexdocs.pm/ecto_watch/upgrading-versions This section details the API reference for the EctoWatch library, outlining modules, functions, and their usage. It serves as a comprehensive guide for developers interacting with EctoWatch's functionalities. ```APIDOC EctoWatch: Overview: Monitors Ecto database changes. Modules: - EctoWatch.Watcher: Manages database watchers and subscriptions. - EctoWatch.Schema: Provides utilities for schema introspection and manipulation. - EctoWatch.Config: Handles configuration options for EctoWatch. Guides: - Getting Started: Basic setup and usage of EctoWatch. - Tracking columns and using labels: How to specify which columns to monitor and assign labels. - Getting additional values: Retrieving extra data associated with database changes. - Watching without a schema: Monitoring changes when a formal Ecto schema is not available. - Unsubscribing: Methods for stopping database watchers. - Trigger Length Errors: Handling and understanding errors related to trigger lengths. - Debugging: Tips and techniques for debugging EctoWatch implementations. - Testing: Strategies for testing EctoWatch integrations. How-To's: - Upgrading Versions: Instructions for migrating between different versions of EctoWatch, including specific guides for upgrading to 0.6.0 and 0.8.0. ``` -------------------------------- ### EctoWatch API Reference Source: https://hexdocs.pm/ecto_watch/tracking-columns-and-using-labels This section details the API reference for EctoWatch, providing information on modules, functions, and their usage. It serves as a comprehensive guide for developers interacting with the library's functionalities. ```APIDOC EctoWatch: __module__ Provides functions for interacting with Ecto database changes. start_link(opts \\ []) Starts the EctoWatch supervisor with the given options. Options: - :ecto_repos: A list of Ecto repositories to monitor. - :watchers: A list of watcher configurations. Returns: {:ok, pid} or {:error, reason} watch(repo, schema, opts \\ []) Starts a watcher for a given Ecto schema in a specific repository. Parameters: - repo: The Ecto repository module. - schema: The Ecto schema module to watch. - opts: Options for the watcher, such as :columns, :labels, :callback. Returns: :ok or {:error, reason} unwatch(repo, schema) Stops watching a specific Ecto schema in a repository. Parameters: - repo: The Ecto repository module. - schema: The Ecto schema module to unwatch. Returns: :ok or {:error, reason} subscribe(topic, handler) Subscribes a handler to a given topic. Parameters: - topic: The topic to subscribe to. - handler: The function to call when a message is received. Returns: :ok or {:error, reason} unsubscribe(topic, handler) Unsubscribes a handler from a given topic. Parameters: - topic: The topic to unsubscribe from. - handler: The handler function to remove. Returns: :ok or {:error, reason} ``` -------------------------------- ### EctoWatch Module Functions Source: https://hexdocs.pm/ecto_watch/trigger-length-errors Provides functions for interacting with EctoWatch, including starting the supervision tree, subscribing to schema changes, and retrieving watcher details. ```APIDOC EctoWatch: child_spec(init_arg) - Creates a child specification for the EctoWatch supervisor. - Parameters: - init_arg: Arguments for initializing the supervisor. details(watcher_identifier) - Retrieves details about a specific watcher. - Parameters: - watcher_identifier: The identifier of the watcher. - Returns: Details of the watcher. init(options) - Initializes the EctoWatch module with given options. - Parameters: - options: Configuration options for EctoWatch. start_link(opts) - Starts the EctoWatch process along with its supervisor. - Parameters: - opts: Options for starting the process. - Returns: {:ok, pid} or {:error, reason}. subscribe(watcher_identifier, id \ nil) - Subscribes to changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher. - id: An optional identifier for the subscription. - Returns: The subscription identifier. subscribe(schema_mod_or_label, update_type, id) - Subscribes to schema changes based on schema module or label and update type. - Parameters: - schema_mod_or_label: The Ecto schema module or a custom label. - update_type: The type of update to subscribe to (e.g., :insert, :update, :delete). - id: An identifier for the subscription. - Returns: The subscription identifier. unsubscribe(watcher_identifier, id \ nil) - Unsubscribes from changes for a given watcher identifier. - Parameters: - watcher_identifier: The identifier of the watcher. - id: The subscription identifier to unsubscribe. - Returns: :ok or {:error, reason}. ``` -------------------------------- ### EctoWatch API Reference Source: https://hexdocs.pm/ecto_watch/unsubscribing This section details the API reference for EctoWatch, outlining modules, functions, and their usage. It serves as a comprehensive guide for developers interacting with the library. ```APIDOC API Reference: - https://hexdocs.pm/ecto_watch/api-reference.html Modules: - https://hexdocs.pm/ecto_watch/api-reference.html#modules Changelog: - https://hexdocs.pm/ecto_watch/changelog.html - Version history includes detailed release notes for each version, e.g., [0.13.3] - 2024-06-19. Guides: - Introduction - Getting Started: https://hexdocs.pm/ecto_watch/getting-started.html - Tracking columns and using labels: https://hexdocs.pm/ecto_watch/tracking-columns-and-using-labels.html - Getting additional values: https://hexdocs.pm/ecto_watch/getting-additional-values.html - Watching without a schema: https://hexdocs.pm/ecto_watch/watching-without-a-schema.html - Unsubscribing: https://hexdocs.pm/ecto_watch/unsubscribing.html#content - Trigger Length Errors: https://hexdocs.pm/ecto_watch/trigger-length-errors.html - Debugging: https://hexdocs.pm/ecto_watch/debugging.html - Testing: https://hexdocs.pm/ecto_watch/testing.html - Notes: https://hexdocs.pm/ecto_watch/notes.html How-To's: - Upgrading Versions: https://hexdocs.pm/ecto_watch/upgrading-versions.html - Upgrading to 0.6.0 - Upgrading to 0.8.0 Other: - Project version history available from v0.1.0 to v0.13.3. ``` -------------------------------- ### EctoWatch API Reference Source: https://hexdocs.pm/ecto_watch/trigger-length-errors This section details the API reference for EctoWatch, outlining modules and their functionalities. It serves as a comprehensive guide to using the library's features programmatically. ```APIDOC EctoWatch: Overview: A library for watching Ecto database changes. Modules: - EctoWatch.Watcher: Manages the watching of database changes. - EctoWatch.Registry: Handles the registration and management of watchers. - EctoWatch.Config: Provides configuration options for EctoWatch. Example Usage: # Start a watcher for a specific schema {:ok, pid} = EctoWatch.Watcher.start_link(schema: MyApp.Repo.MySchema) # Subscribe to changes EctoWatch.Registry.subscribe(pid, self()) # Handle received changes # receive do # {:ecto_watch, %{event: :insert, data: record}} # ... # end Configuration: # config :ecto_watch, # log_level: :info Related Guides: - Getting Started: https://hexdocs.pm/ecto_watch/getting-started.html - Tracking columns and using labels: https://hexdocs.pm/ecto_watch/tracking-columns-and-using-labels.html ``` -------------------------------- ### Handling EctoWatch Notifications in LiveView Source: https://hexdocs.pm/ecto_watch/getting-started Provides examples of how to handle incoming EctoWatch notifications within a LiveView's `handle_info` callback. This includes updating streamed data based on inserted, updated, or deleted records. ```elixir def handle_info({:user_inserted, %{id: id}}, socket) do user = Accounts.get_user(id) socket = stream_insert(socket, :users, user) {:noreply, socket} end def handle_info({:user_updated, %{id: id}}, socket) do user = Accounts.get_user(id) socket = stream_insert(socket, :users, user) {:noreply, socket} end def handle_info({:user_deleted, %{id: id}}, socket) do socket = stream_delete_by_dom_id(socket, :users, "users-#{id}") {:noreply, socket} end ``` -------------------------------- ### EctoWatch Modules Overview Source: https://hexdocs.pm/ecto_watch/index Provides an overview of the EctoWatch library modules, including EctoWatch, EctoWatch.WatcherServer, EctoWatch.WatcherSupervisor, and EctoWatch.WatcherTriggerValidator. Links to HexDocs and related resources are included. ```elixir ## Modules [EctoWatch](https://hexdocs.pm/ecto_watch/EctoWatch.html) [EctoWatch.WatcherServer](https://hexdocs.pm/ecto_watch/EctoWatch.WatcherServer.html) [EctoWatch.WatcherSupervisor](https://hexdocs.pm/ecto_watch/EctoWatch.WatcherSupervisor.html) [EctoWatch.WatcherTriggerValidator](https://hexdocs.pm/ecto_watch/EctoWatch.WatcherTriggerValidator.html) ``` -------------------------------- ### EctoWatch Configuration for Debugging Source: https://hexdocs.pm/ecto_watch/debugging This snippet shows the basic configuration for EctoWatch, including how to set up watchers and enable debugging. Debug logs are written to the `:debug` log level. ```elixir setup(EctoWatch, repo: MyApp.Repo, pub_sub: MyApp.PubSub, watchers: [# ...{Comment,:deleted,debug?:true,extra_columns:[:post_id]},# ...]) ``` -------------------------------- ### EctoWatch API Reference Source: https://hexdocs.pm/ecto_watch/getting-started Provides detailed API documentation for the EctoWatch library, including modules, functions, and their usage. This is the primary reference for interacting with EctoWatch programmatically. ```APIDOC EctoWatch: Overview: A library for watching changes in Ecto schemas and databases. Modules: - EctoWatch.Watcher: Handles the core logic for setting up and managing database watches. - EctoWatch.Schema: Provides utilities for working with Ecto schemas. - EctoWatch.Config: Manages the configuration for EctoWatch. Key Concepts: - Watching: Actively monitoring specific tables or schemas for changes. - Subscribing/Unsubscribing: Managing the flow of change notifications. - Labels: Tagging watched data for easier filtering and identification. Example Usage (Conceptual): # Start watching a schema EctoWatch.Watcher.start_link(schema: MyApp.Repo.Schema) # Subscribe to changes EctoWatch.Watcher.subscribe(pid, fn changes -> IO.inspect(changes) end) Further Reading: - [Getting Started](https://hexdocs.pm/ecto_watch/getting-started.html) - [Tracking columns and using labels](https://hexdocs.pm/ecto_watch/tracking-columns-and-using-labels.html) - [Watching without a schema](https://hexdocs.pm/ecto_watch/watching-without-a-schema.html) ``` -------------------------------- ### EctoWatch: Documentation for labels and identifiers Source: https://hexdocs.pm/ecto_watch/changelog Includes documentation explaining the use of labels and how to handle potential issues with overly long PostgreSQL identifiers, ensuring users can configure watchers effectively. ```elixir # Example of using labels with a watcher EctoWatch.watch( schema: MySchema, label: "my_watcher_label" ) ```