aboutsummaryrefslogtreecommitdiff
path: root/lib/Plugins.Essentials.ServiceStack/README.md
blob: aa334350b06e8199c3372bdbb674000f7db3cee9 (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
66
67
68
# VNLib.Plugins.Essentials.ServiceStack

This library contains all of the utilities required for an application to build VNLib.Net.Http.HttpServer listeners for nearly unlimited virtual hosts.

#### Builds
Debug build w/ symbols & xml docs, release builds, NuGet packages, and individually packaged source code are available on my [website](https://www.vaughnnugent.com/resources/software). All tar-gzip (.tgz) files will have an associated .sha384 appended checksum of the desired download file.

### Breakdown

**HttpServiceStack** - This immutable data structure represents a collection of listening HttpServer instances across the ServiceDomain, and manages the entire lifecycle of those servers.

**ServiceDomain** - The immutable collection of ServiceGroups and their dynamically loaded plugins that represent the bindings between the listening servers and their application code. The service domain handles plugin reload events and their dynamic endpoint updates.

**ServiceGroup** - The immutable collection of service hosts that will share a common HttpServer because they have the same endpoint and TLS/SSL status (enabled or not)

**IServiceHost** - Represents an immutable container exposing the EventProcessor used to execute host specific operations and the transport information (IHostTransportInfo)

**IHostTransportInfo** - The service transport information (desired network endpoint to listen on, and an optional X509Certificate)

**HttpServiceStackBuilder** - The builder class used to build the HttpServiceStack

## Usage
Again, this library may be used broadly and therefor I will only show basic usage to generate listeners for applications.

```programming language C#
public static int main (string[] args)
{
   //Start with the new builder
   HttpServiceStackBuilder builder = new();
   
   //Build the service domain by loading all IServiceHosts
   bool built = builder.ServiceDomain.BuildDomain( hostCollection => ... );
   
   //Check status
   if(!built)
   {
      return -1;
   }
   
   //Load dynamic plugins
   Task loading = builder.ServiceDomain.LoadPlugins(<hostConfig>,<IlogProvider>);
   //wait for loading, we don't need to but if plugins don't load we may choose to exit
   loading.Wait();
   
   //Builds servers by retrieving required ITransportProvider for each service group
   builder.BuildServers(<HttpConfig>, group => ... );
   
   //Get service stack, in a using statement to cleanup. 
   using HttpServiceStack serviceStack = builder.ServiceStack;
   
   //Start servers
   serviceStack.StartServers();
  
   ... Wait for process exit
   
   //Stop servers and exit process
   serviceStack.StopAndWaitAsync().Wait();
   
  return 0;
}
```

## License

The software in this repository is licensed under the GNU Affero General Public License (or any later version).
See the LICENSE files for more information.