Skip to content

Commit

Permalink
feat: dynamic server nomad calls
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelOnFira committed Jul 19, 2024
1 parent 8760618 commit 9dfbcae
Show file tree
Hide file tree
Showing 235 changed files with 24,005 additions and 1,692 deletions.
3 changes: 3 additions & 0 deletions .vscode/rivet.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
{
"path": "../lib/bolt",
},
{
"path": "../svc",
}
],
}
File renamed without changes.
10 changes: 10 additions & 0 deletions errors/servers/servers_must_specify_routing_type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name = "SERVERS_MUST_SPECIFY_ROUTING_TYPE"
description = "Must specify routing type."
http_status = 400
---

# Must Specify Routing Type

Must specify either `game_guard` or `host` routing type.

File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions errors/servers/servers_server_not_found.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
name = "SERVERS_SERVER_NOT_FOUND"
description = "Server not found."
http_status = 400
---

# Server Not Found

Server not found for the given ID.
10 changes: 10 additions & 0 deletions errors/servers/servers_unsupported_host_protocol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name = "SERVERS_UNSUPPORTED_HOST_PROTOCOL"
description = "Unsupported host protocol."
http_status = 400
---

# Unsupported Host Protocol

Host protocol must use the TCP or UDP protocol.

3 changes: 3 additions & 0 deletions fern/definition/cloud/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ types:
complete:
docs: Whether or not this build has completely been uploaded.
type: boolean
tags:
docs: Tags of this build
type: map<string, string>

CdnSiteSummary:
docs: A CDN site summary.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,28 @@ imports:

service:
auth: true
base-path: /servers/servers
base-path: /servers
endpoints:
get:
path: /{server_id}
method: GET
docs: Gets a dynamic server.
path-parameters:
server_id:
docs: The id of the server to destroy
type: uuid
response: GetServerResponse

create:
path: ""
method: POST
docs: Create a new dynamic server.
request:
body: CreateServerRequest
response: CreateServerResponse

destroy:
path: "/{server_id}"
path: /{server_id}
method: DELETE
docs: Destroy a dynamic server.
path-parameters:
Expand All @@ -33,27 +44,69 @@ service:
type: optional<long>
response: DestroyServerResponse

list:
path: /list
method: GET
docs: >-
Lists all servers associated with the token used. Can be filtered by
tags in the query string.
request:
name: GetServersRequest
query-parameters:
tags: optional<string>
response: ListServersResponse

types:
GetServerResponse:
properties:
server: commons.Server

CreateServerRequest:
properties:
datacenter:
docs: The name ID of the datacenter
type: string
metadata: unknown
tags: unknown
image_id: uuid
arguments: optional<list<string>>
environment: optional<map<string, string>>
network: CreateServerNetworkRequest
resources: commons.Resources
kill_timeout:
docs: >-
The duration to wait for in milliseconds before killing the server.
This should be set to a safe default, and can be overridden during a
DELETE request if needed.
type: optional<long>
runtime: commons.Runtime
webhook_url:
docs: >-
A url to send to which events from the server running will be sent
type: optional<string>

CreateServerNetworkRequest:
properties:
mode: optional<commons.NetworkMode>
ports: map<string, CreateServerPortRequest>

CreateServerPortRequest:
properties:
protocol: commons.PortProtocol
server_port: optional<integer>
routing: optional<commons.PortRouting>

CreateServerResponse:
properties:
server:
docs: The server that was created
type: commons.Server

DestroyServerResponse:
properties:
server_id:
type: uuid

ListServersResponse:
properties:
builds:
docs: A list of build summaries.
type: list<commons.Server>
81 changes: 81 additions & 0 deletions fern/definition/servers/builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json

imports:
commons: ../common.yml
uploadCommons: ../upload/common.yml
cloudCommons: ../cloud/common.yml

service:
auth: true
base-path: /servers
endpoints:
listBuilds:
path: /builds
method: GET
docs: >-
Lists all builds of the game associated with the token used. Can be
filtered by tags in the query string.
request:
name: GetBuildsRequest
query-parameters:
tags: optional<string>
response: ListBuildsResponse

prepareBuild:
path: /builds
method: POST
docs: Creates a new game build for the given game.
request:
body: CreateBuildRequest
response: CreateBuildResponse

completeBuild:
path: /uploads/{upload_id}/complete
method: POST
docs: Marks an upload as complete.
path-parameters:
upload_id:
type: uuid

types:
ListBuildsResponse:
properties:
builds:
docs: A list of build summaries.
type: list<cloudCommons.BuildSummary>

CreateBuildRequest:
properties:
display_name: commons.DisplayName
tags: unknown
image_tag:
docs: A tag given to the game build.
type: string
image_file: uploadCommons.PrepareFile
multipart_upload:
type: optional<boolean>
kind: optional<BuildKind>
compression: optional<BuildCompression>

CreateBuildResponse:
properties:
build_id:
type: uuid
upload_id:
type: uuid
image_presigned_request: optional<uploadCommons.PresignedRequest>
image_presigned_requests: optional<list<uploadCommons.PresignedRequest>>

BuildKind:
enum:
- value: docker_image
docs: Docker image archive generated by `docker save`.
- value: oci_bundle
docs: OCI-compliant bundle.

BuildCompression:
enum:
- value: none
docs: None compression.
- value: lz4
docs: LZ4 compression. Use the minimum compression level.
59 changes: 27 additions & 32 deletions fern/definition/servers/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ types:
game_id: uuid
datacenter_id: uuid
cluster_id: uuid
metadata: unknown
tags: unknown
image_id: uuid
arguments: optional<list<string>>
environment: optional<map<string, string>>
network: Network
resources: Resources
kill_timeout:
docs: >-
The duration to wait for in milliseconds before killing the server.
This should be set to a safe default, and can be overridden during a
DELETE request if needed.
type: optional<long>
runtime: Runtime
create_ts: long
destroy_ts: optional<long>

Expand All @@ -31,48 +34,40 @@ types:
docs: The amount of memory in megabytes
type: integer

Runtime:
properties:
docker: optional<DockerRuntime>

DockerRuntime:
properties:
image_id: uuid
args: optional<list<string>>
environment: optional<map<string, string>>
network: DockerNetwork

DockerNetwork:
Network:
properties:
mode: optional<DockerNetworkMode>
ports: map<string, DockerPort>
mode: optional<NetworkMode>
ports: map<string, Port>

DockerNetworkMode:
NetworkMode:
enum:
- bridge
- host

DockerPort:
Port:
properties:
port: optional<integer>
routing: DockerPortRouting
protocol: PortProtocol
server_port: optional<integer>
public_hostname: optional<string>
public_port: optional<integer>
routing: PortRouting

DockerPortRouting:
properties:
game_guard: optional<DockerGameGuardRouting>
host: optional<DockerHostRouting>

DockerGameGuardRouting:
properties:
protocol: optional<GameGuardProtocol>

GameGuardProtocol:
PortProtocol:
enum:
- http
- https
- tcp
- tcp_tls
- udp

DockerHostRouting:
properties: {}
PortRouting:
properties:
game_guard: optional<GameGuardRouting>
host: optional<HostRouting>

GameGuardRouting:
properties: {}

HostRouting:
properties: {}

25 changes: 25 additions & 0 deletions infra/default-builds/dockerfiles/test-ds-echo/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Created by https://www.toptal.com/developers/gitignore/api/rust
# Edit at https://www.toptal.com/developers/gitignore?templates=rust

### Rust ###
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# End of https://www.toptal.com/developers/gitignore/api/rust

.dockerignore
.gitignore
Dockerfile

21 changes: 21 additions & 0 deletions infra/default-builds/dockerfiles/test-ds-echo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Created by https://www.toptal.com/developers/gitignore/api/rust
# Edit at https://www.toptal.com/developers/gitignore?templates=rust

### Rust ###
# Generated by Cargo
# will have compiled files and executables
debug/
target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# End of https://www.toptal.com/developers/gitignore/api/rust

16 changes: 16 additions & 0 deletions infra/default-builds/dockerfiles/test-ds-echo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "test-ds-echo"
version = "0.1.0"
edition = "2021"

[dependencies]
tokio = { version = "1.29", features = ["full"] }
reqwest = "0.11"
anyhow = "1.0"
hyper = { version = "0.14", features = ["server"] }

[profile.release]
opt-level = 'z'
lto = true
codegen-units = 1

Loading

0 comments on commit 9dfbcae

Please sign in to comment.