Playwright.Channel.Catalog (playwright v1.18.0-alpha.1) View Source

Provides storage and management of ChannelOwner instances.

Catalog implements GenServer to maintain state, while domain logic is expected to be handled within caller modules such as Playwright.Channel.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Retrieves a resource from the Catalog by its param: guid.

Returns a List of resources matching the provided "filter".

Adds a resource to the Catalog, keyed on :guid.

Removes a resource from the Catalog, along with its legacy.

Starts a Playwright.Channel.Catalog linked to the current process with the given "root" resource.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

get(catalog, guid, options \\ %{})

View Source

Specs

get(pid(), binary(), map()) :: struct() | {:error, Playwright.Channel.Error.t()}

Retrieves a resource from the Catalog by its param: guid.

If the resource is already present in the Catalog that resource is returned directly. The desired resource might not yet be in the Catalog, in which case the request will be considered as "awaiting". An awaiting request will later receive a response, when the Catalog entry is made, or will time out.

Returns

  • resource
  • {:error, error}

Arguments

key/nametypedescription
catalogparampid()PID for the Catalog server
guidparambinary()GUID to look up
:timeoutoptionfloat()Maximum time to wait, in milliseconds. Defaults to 30_000 (30 seconds).

Specs

list(pid(), map()) :: [struct()]

Returns a List of resources matching the provided "filter".

Returns

  • [resource]
  • []

Arguments

key/nametypedescription
catalogparampid()PID for the Catalog server
filterparammap()Attributes for filtering

Specs

put(
  pid(),
  struct()
) :: struct()

Adds a resource to the Catalog, keyed on :guid.

Returns

  • resource (the same as provided)

Arguments

key/nametypedescription
catalogparampid()PID for the Catalog server
resourceparamstruct()The resource to store

Specs

rm_r(pid(), binary()) :: :ok

Removes a resource from the Catalog, along with its legacy.

Returns

  • :ok

Arguments

key/nametypedescription
catalogparampid()PID for the Catalog server
guidparambinary()GUID for the "parent"

Specs

start_link(map()) :: {:ok, pid()}

Starts a Playwright.Channel.Catalog linked to the current process with the given "root" resource.

Return Values

If the Catalog is successfully created and initialized, the function returns {:ok, pid}, where pid is the PID of the running Catalog server.

Arguments

key/nametypedescription
rootparammap()The root resource for items in the Catalog. Provides the Session for its descendants