UNPKG

1.52 kBJavaScriptView Raw
1/*
2 * Copyright (c) 2018 One Hill Technologies, LLC
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17const { BO } = require ('base-object');
18const { Events } = require ('./messaging');
19
20/**
21 * @class Service
22 *
23 * The service represents an abstraction that runs in the background while the
24 * application is live.
25 */
26module.exports = BO.extend (Events, {
27 /// The hosting application for the service.
28 app: null,
29
30 /**
31 * Instruct the service to configure itself. We have the configure() method
32 * because the init() method is synchronous. It is therefore hard for the service
33 * to call methods that are asynchronous during configuration. The configure
34 * method allows this because you can return a Promise, if needed.
35 *
36 * @return {Promise|null}
37 */
38 configure () {
39 return null;
40 },
41
42 /**
43 * Destroy the service.
44 */
45 destroy () {
46 return null;
47 },
48
49 /**
50 * Instruct the service to start.
51 *
52 * @return {Promise|null}
53 */
54 start () {
55 return null;
56 }
57});
\No newline at end of file