aboutsummaryrefslogtreecommitdiff
path: root/lib/Plugins.Essentials.ServiceStack/src/IServiceHost.cs
blob: 2b5dc6440e0b71029b6fdf6a0d1effa6cf532539 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Copyright (c) 2024 Vaughn Nugent
* 
* Library: VNLib
* Package: VNLib.Plugins.Essentials.ServiceStack
* File: IServiceHost.cs 
*
* IServiceHost.cs is part of VNLib.Plugins.Essentials.ServiceStack which is part of the larger 
* VNLib collection of libraries and utilities.
*
* VNLib.Plugins.Essentials.ServiceStack is free software: you can redistribute it and/or modify 
* it under the terms of the GNU Affero General Public License as 
* published by the Free Software Foundation, either version 2 of the
* License, or (at your option) any later version.
*
* VNLib.Plugins.Essentials.ServiceStack is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program.  If not, see https://www.gnu.org/licenses/.
*/

using VNLib.Net.Http;
using VNLib.Plugins.Essentials.ServiceStack.Plugins;

namespace VNLib.Plugins.Essentials.ServiceStack
{
    /// <summary>
    /// Represents an HTTP service host which provides information required 
    /// for HttpServer routing and the <see cref="IWebRoot"/> for proccessing
    /// incomming connections
    /// </summary>
    public interface IServiceHost
    {
        /// <summary>
        /// The <see cref="IWebRoot"/> that handles HTTP connection 
        /// processing.
        /// </summary>
        IWebRoot Processor { get; }

        /// <summary>
        /// Optional user state to be set during initialization and read at a later time
        /// </summary>
        object? UserState { get; }
      
        /// <summary>
        /// Called when a plugin is loaded and is endpoints are extracted
        /// to be placed into service.
        /// </summary>
        /// <param name="plugin">The loaded plugin ready to be attached</param>
        /// <param name="endpoints">The dynamic endpoints of a loading plugin</param>
        void OnRuntimeServiceAttach(IManagedPlugin plugin, IEndpoint[] endpoints);

        /// <summary>
        /// Called when a <see cref="ServiceDomain"/>'s <see cref="IHttpPluginManager"/> 
        /// unloads a given plugin, and its originally discovered endpoints
        /// </summary>
        /// <param name="plugin">The unloading plugin to detach</param>
        /// <param name="endpoints">The endpoints of the unloading plugin to remove from service</param>
        void OnRuntimeServiceDetach(IManagedPlugin plugin, IEndpoint[] endpoints);

    }
}