NAME

Ubic::Multiservice - interface of multiservice representing several named services

VERSION

version 1.45

SYNOPSIS

$service = $multiservice->service("multiservice-x.multiservice-y.service-z");
@services = $multiservice->services();

DESCRIPTION

Multiservices are objects with simple list/get API which is used to fill ubic service tree.

This is an abstract base class for all multiservices.

Actual multiservice classes should inherit from this class and implement methods from "ABSTRACT METHODS" section.

ABSTRACT METHODS

These methods have to be overloaded by subclasses:

simple_service($name)

Should return subservice by its short name (i.e. name without dot separators in it).

service_names()

Should return list with the names of all top-level subservices.

METHODS

These methods can be overloaded for a performance boost or some non-trivial tasks, but their default implementation should be adequate in 99% of the cases.

service($name)

Get service by name.

This class provides a common implementation which can delegate searching of subservices to multiservices (don't panic!), so subclasses should implement simple_service instead.

All subservices are cached forever.

has_service($name)

Check whether service with specified name exists in this multiservice.

Like service, subclasses should usually implement has_simple_service instead.

services()

Construct all top-level subservices.

By default, it uses service_names to get the list of names.

has_simple_service($name)

Returns true if $name is a subservice of this multiservice.

Default implementation calls $self->service_names, so you might want to reimplement it in subclasses for a performance reasons.

multiop()

Get multiop operation mode of a multiservice. There are three possible values which this method can return:

allowed

start, stop, restart actions for this module start/stop/restart all subservices. This is the default.

protected

-f flag in ubic(1) binary is required to call any action.

forbidden

ubic(1) binary will refuse to start/stop/restart this multiservice.

BUGS AND CAVEATS

Although multiservice class is inherited from Ubic::Service class, it doesn't and shouldn't implement start/stop/status methods. This is because user will usually want to see action's progress, and all output policy is defined in Ubic::Cmd class; interaction protocol between this class and Ubic::Cmd class would be too complex.

This may be fixed in future: either Ubic::Multiservice will no longer inherit from Ubic::Service, or start/stop methods will be implemented with renderer object as an argument. Until then, please don't override these methods in subclasses.

user, group and other metadata methods are not used for multiservices too.

Subservices are cached forever; this can cause troubles, but it is necessary to avoid memory leaks in persistent programs, for example, in Ubic::Ping.

SEE ALSO

Ubic::Multiservice::Simple - class for defining simple multiservices.

Ubic::Multiservice::Dir - multiservice which loads service configs from files.

AUTHOR

Vyacheslav Matyukhin <mmcleric@yandex-team.ru>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Yandex LLC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.