aboutsummaryrefslogtreecommitdiff
path: root/zenserver/config.h
blob: 55e846352027f3cc27d1d8b4eb0378828db3a815 (plain) (blame)
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
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include <filesystem>
#include <string>
#include <vector>

#ifndef ZEN_ENABLE_MESH
#	define ZEN_ENABLE_MESH 0
#endif

struct ZenServerOptions
{
	bool				  IsDebug	  = false;
	bool				  IsTest	  = false;
	bool				  IsDedicated = false;		 // Indicates a dedicated/shared instance, with larger resource requirements
	int					  BasePort	  = 1337;		 // Service listen port (used for both UDP and TCP)
	int					  OwnerPid	  = 0;			 // Parent process id (zero for standalone)
	std::string			  ChildId;					 // Id assigned by parent process (used for lifetime management)
	bool				  InstallService   = false;	 // Flag used to initiate service install (temporary)
	bool				  UninstallService = false;	 // Flag used to initiate service uninstall (temporary)
	std::string			  LogId;					 // Id for tagging log output
	std::filesystem::path DataDir;					 // Root directory for state (used for testing)
	std::filesystem::path ContentDir;				 // Root directory for serving frontend content (experimental)
	std::string			  HttpServerClass;			 // Choice of HTTP server implementation
	std::filesystem::path AbsLogFile;				 // Absolute path to main log file
};

struct ZenUpstreamJupiterConfig
{
	std::string Url;
	std::string OAuthProvider;
	std::string OAuthClientId;
	std::string OAuthClientSecret;
	std::string Namespace;
	std::string DdcNamespace;
	bool		UseDevelopmentSettings = false;
	bool		UseProductionSettings  = false;
	bool		UseLegacyDdc		   = false;
};

struct ZenUpstreamZenConfig
{
	std::vector<std::string> Urls;
	std::vector<std::string> Dns;
};

enum class UpstreamCachePolicy : uint8_t
{
	Disabled  = 0,
	Read	  = 1 << 0,
	Write	  = 1 << 1,
	ReadWrite = Read | Write
};

struct ZenUpstreamCacheConfig
{
	ZenUpstreamJupiterConfig JupiterConfig;
	ZenUpstreamZenConfig	 ZenConfig;
	int						 UpstreamThreadCount = 4;
	UpstreamCachePolicy		 CachePolicy		 = UpstreamCachePolicy::ReadWrite;
	bool					 StatsEnabled		 = false;
};

struct ZenServiceConfig
{
	bool StructuredCacheEnabled = true;
	bool ShouldCrash			= false;  // Option for testing crash handling
	bool IsFirstRun				= false;
#if ZEN_ENABLE_MESH
	bool MeshEnabled = false;  // Experimental p2p mesh discovery
#endif
	ZenUpstreamCacheConfig UpstreamCacheConfig;
};

void ParseGlobalCliOptions(int argc, char* argv[], ZenServerOptions& GlobalOptions, ZenServiceConfig& ServiceConfig);
void ParseServiceConfig(const std::filesystem::path& DataRoot, ZenServiceConfig& ServiceConfig);