blogit v1.2.3 Blogit.Components.PostsByDate View Source
A Blogit.Component
process which can be queried from outside.
This process handles a :get
message which returns a list of tuples of
three elements - {<year>, <month>, <number-of-posts>}
. It is statistics
data - for this year and this month the blog has N posts.
This component is supervised by Blogit.Components.Supervisor
and added to
it by Blogit.Server
. It is lazy, the first time it is queried it computes
its state by using the Blogit.Components.Posts
process' state.
When the posts get updated, this process' state is reset to nil
and on the
next request to it, it is re-calculated.
Link to this section Summary
Functions
Returns the base name, which identifies the process. For example it
could be posts
.
Returns a specification to start this module under a supervisor.
Callback implementation for GenServer.init/1
.
Returns the name, which identifies the process. It is composed using the
base_name/0
and the given language
. For example if the base_name/0
returns posts
and the given language is en
, the name will be
posts_en
.
Link to this section Functions
Returns the base name, which identifies the process. For example it
could be posts
.
Returns a specification to start this module under a supervisor.
See Supervisor
.
Callback implementation for GenServer.init/1
.
name(language)
View Sourcename(String.t()) :: atom()
name(String.t()) :: GenServer.on_start()
Returns the name, which identifies the process. It is composed using the
base_name/0
and the given language
. For example if the base_name/0
returns posts
and the given language is en
, the name will be
posts_en
.
The worker id registered under the Blogit.Components.Supervisor
will
be the name returned by this function, when start_link/1
is called
to create the process. The language passed to it
(or the one returned from Blogit.Settings.default_language/0
) will be
passed to name/1
to create the name.
start_link(language \\ Settings.default_language(), state_provider \\ Blogit.Server)
View SourceStarts the GenServer
process.
The process is started and supervised by Blogit.Components.Supervisor
and the specification of it is added by Blogit.Server
.
The state of the process in the beginning is nil.
The process should keep the given language
passed to init/1
as the first of a tuple as part of its state. This process should serve
requests related to that language
.
The given state_provider
is the second element of the tuple passed to
GenServer.init/1
. It could be used to retrieve the state of
the process.
By default the language
is the one returned by
Blogit.Settings.default_language/0
and the state_provider
is
Blogit.Server
.