Module z_pivot_rsc

Pivoting server for the rsc table.

Copyright © 2009-2020 Marc Worrell, Maas-Maarten Zeeman

Behaviours: gen_server.

Authors: Marc Worrell (marc@worrell.nl).

Description

Pivoting server for the rsc table. Takes care of full text indices. Polls the pivot queue for any changed resources.

Function Index

cleanup_tsv_text/1
code_change/3Convert process state when code is changed.
define_custom_pivot/3Let a module define a custom pivot columns() -> [column()] column() -> {ColumName::atom(), ColSpec::string()} | {atom(), string(), options::list()}.
delete_task/3
delete_task/4
delete_tasks/1
get_pivot_title/1
get_pivot_title/2Fetch the first title from the record for sorting.
get_task/1
get_task/2
get_task/3
get_task/4
handle_call/3Handle task_done messages from task queue jobs.
handle_cast/2Poll the queue for the default host.
handle_info/2Handling all non call/cast messages.
init/1Initiates the server.
insert_queue/2Insert a rsc_id in the pivot queue.
insert_task/3Insert a slow running pivot task.
insert_task/4Insert a slow running pivot task.
insert_task/5Insert a slow running pivot task with unique key and arguments.
insert_task_after/6Insert a slow running pivot task with unique key and arguments that should start after Seconds seconds.
list_tasks/1
lookup_custom_pivot/4Lookup a custom pivot; give back the Id based on a column.
pg_lang/1Translate a language to a language string as used by postgresql.
pg_lang_extra/1
pivot/2An immediate pivot request for a resource.
pivot_delay/1Delay the next pivot, useful when performing big updates.
pivot_resource_update/4Return a modified property list with fields that need immediate pivoting on an update.
poll/1Poll the pivot queue for the database in the context.
queue_all/1Rebuild the search index by queueing all resources for pivot.
queue_count/1Return the length of the pivot queue.
start_link/1Starts the server.
status/1
stemmer_language/1Return the language used for stemming the full text index.
stemmer_language_config/1
terminate/2This function is called by a gen_server when it is about to terminate.

Function Details

cleanup_tsv_text/1

cleanup_tsv_text(Text::binary()) -> binary()

code_change/3

code_change(OldVsn, State, Extra) -> any()

Convert process state when code is changed

define_custom_pivot/3

define_custom_pivot(Module, Columns::columns(), Context) -> ok

Let a module define a custom pivot columns() -> [column()] column() -> {ColumName::atom(), ColSpec::string()} | {atom(), string(), options::list()}

delete_task/3

delete_task(Module::module(), Function::atom(), Context::z:context()) -> non_neg_integer()

delete_task/4

delete_task(Module::module(), Function::atom(), UniqueKey::term(), Context::z:context()) -> non_neg_integer()

delete_tasks/1

delete_tasks(Context::z:context()) -> non_neg_integer()

get_pivot_title/1

get_pivot_title(Props) -> any()

get_pivot_title/2

get_pivot_title(Id, Context) -> any()

Fetch the first title from the record for sorting.

get_task/1

get_task(Context::z:context()) -> {ok, [map()]} | {error, term()}

get_task/2

get_task(Module::module(), Context::z:context()) -> {ok, [map()]} | {error, term()}

get_task/3

get_task(Module::module(), Function::atom(), Context::z:context()) -> {ok, [map()]} | {error, term()}

get_task/4

get_task(Module::module(), Function::atom(), UniqueKey::binary() | string(), Context::z:context()) -> {ok, map()} | {error, term()}

handle_call/3

handle_call(Message, From, State) -> any()

Handle task_done messages from task queue jobs

handle_cast/2

handle_cast(Message, State) -> any()

Poll the queue for the default host

handle_info/2

handle_info(Info, State) -> any()

Handling all non call/cast messages

init/1

init(Site::Args) -> {ok, State} | {ok, State, Timeout} | ignore | {stop, Reason}

Initiates the server.

insert_queue/2

insert_queue(IdorIds::m_rsc:resource_id() | [m_rsc:resource_id()], Context::z:context()) -> ok | {error, eexist}

Insert a rsc_id in the pivot queue

insert_task/3

insert_task(Module, Function, Context) -> any()

Insert a slow running pivot task. For example syncing category numbers after an category update.

insert_task/4

insert_task(Module, Function, UniqueKey, Context) -> any()

Insert a slow running pivot task. Use the UniqueKey to prevent double queued tasks.

insert_task/5

insert_task(Module, Function, UniqueKey, Args, Context) -> any()

Insert a slow running pivot task with unique key and arguments.

insert_task_after/6

insert_task_after(SecondsOrDate, Module, Function, UniqueKey, ArgsFun, Context) -> any()

Insert a slow running pivot task with unique key and arguments that should start after Seconds seconds. Always delete any existing transaction, to prevent race conditions when the task is running during this insert.

list_tasks/1

list_tasks(Context::z:context()) -> {ok, [map()]} | {error, term()}

lookup_custom_pivot/4

lookup_custom_pivot(Module, Column, Value, Context) -> Id | undefined

Lookup a custom pivot; give back the Id based on a column. Will always return the first Id found.

pg_lang/1

pg_lang(X1) -> any()

Translate a language to a language string as used by postgresql. This language list is the intersection of the default catalogs of postgres with the languages supported by mod_translation.

pg_lang_extra/1

pg_lang_extra(LangCode) -> any()

pivot/2

pivot(Id::integer(), Context::#context{}) -> ok

An immediate pivot request for a resource

pivot_delay/1

pivot_delay(Context::#context{}) -> ok

Delay the next pivot, useful when performing big updates

pivot_resource_update/4

pivot_resource_update(Id, UpdateProps, RawProps, Context) -> any()

Return a modified property list with fields that need immediate pivoting on an update.

poll/1

poll(Context) -> void()

Poll the pivot queue for the database in the context

queue_all/1

queue_all(Context) -> any()

Rebuild the search index by queueing all resources for pivot.

queue_count/1

queue_count(Context::z:context()) -> integer()

Return the length of the pivot queue.

start_link/1

start_link(SiteProps) -> {ok, Pid} | ignore | {error, Error}

Starts the server

status/1

status(Context::z:context()) -> {ok, map()} | {error, term()}

stemmer_language/1

stemmer_language(Context::#context{}) -> string()

Return the language used for stemming the full text index. We use a single stemming to prevent having seperate indexes per language.

stemmer_language_config/1

stemmer_language_config(Context::#context{}) -> atom()

terminate/2

terminate(Reason, State) -> any()

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.


Generated by EDoc