This repository was archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathVcapApplication.cs
127 lines (109 loc) · 4.13 KB
/
VcapApplication.cs
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// -----------------------------------------------------------------------
// <copyright file="VcapApplication.cs" company="Petabridge, LLC">
// Copyright (C) 2018 - 2018 Petabridge, LLC <https://petabridge.com>
// </copyright>
// -----------------------------------------------------------------------
using System.Collections.Generic;
using System.Text;
namespace Akka.Bootstrap.PCF
{
/// <summary>
/// Exposes the values from the VCAP_SERVICES PCF environment variable.
/// </summary>
/// <remarks>
/// See https://docs.run.pivotal.io/devguide/deploy-apps/environment-variable.html for more details.
/// </remarks>
public sealed class VcapApplication
{
public VcapApplication(string applicationId, string applicationName, IReadOnlyList<string> applicationUris,
string applicationVersion, string cfApi, AppResourceLimits limits, string name,
string spaceId, string spaceName, IReadOnlyList<string> uris, string version)
{
ApplicationId = applicationId;
ApplicationName = applicationName;
ApplicationUris = applicationUris;
ApplicationVersion = applicationVersion;
CfApi = cfApi;
Limits = limits;
Name = name;
SpaceId = spaceId;
SpaceName = spaceName;
Uris = uris;
Version = version;
}
public string ApplicationId { get; }
public string ApplicationName { get; }
public IReadOnlyList<string> ApplicationUris { get; }
public string ApplicationVersion { get; }
/// <summary>
/// The URI of the Cloud Foundry host endpoint.
/// </summary>
public string CfApi { get; }
public AppResourceLimits Limits { get; }
public string Name { get; }
public string SpaceId { get; }
public string SpaceName { get; }
public IReadOnlyList<string> Uris { get; }
public string Version { get; }
public override string ToString()
{
var sb = new StringBuilder();
return ToString(sb);
}
public string ToString(StringBuilder sb)
{
sb.AppendLine("VCAP_APPLICATION:")
.AppendLine($" ApplicationId: {ApplicationId}")
.AppendLine($" ApplicationName: {ApplicationName}")
.AppendLine($" ApplicationVersion: {ApplicationVersion}")
.AppendLine(" ApplicationUris:");
foreach (var uri in ApplicationUris)
sb.AppendLine(" " + uri);
sb.AppendLine($" CfApi: {CfApi}")
.AppendLine($" Name: {Name}")
.AppendLine($" SpaceId: {SpaceId}")
.AppendLine($" SpaceName: {SpaceName}")
.AppendLine($" Version: {Version}")
.AppendLine(" Uris:");
foreach (var uri in Uris)
sb.AppendLine(" " + uri);
return Limits.ToString(sb);
}
}
/// <summary>
/// Limits on application resources in PCF at the moment when this application was booted.
/// </summary>
public sealed class AppResourceLimits
{
public AppResourceLimits(int disk, int fds, int mem)
{
Disk = disk;
Fds = fds;
Mem = mem;
}
/// <summary>
/// Disk consumption limits in megabytes.
/// </summary>
public int Disk { get; }
/// <summary>
/// The number of allowed file descriptors.
/// </summary>
public int Fds { get; }
/// <summary>
/// The amount of available memory in megabytes.
/// </summary>
public int Mem { get; }
public override string ToString()
{
var sb = new StringBuilder();
return ToString(sb);
}
public string ToString(StringBuilder sb)
{
return sb.AppendLine("Limits:")
.AppendLine($" Disk: {Disk}")
.AppendLine($" Memory: {Mem}")
.AppendLine($" FileDescriptors: {Fds}").ToString();
}
}
}