Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broad, sweeping improvements #37

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a8ecd89
Improve retry system
brandonsturgeon Jun 18, 2023
ef50967
Add tests, refactor retries slightly
brandonsturgeon Jun 19, 2023
afa20d4
lol
brandonsturgeon Jun 19, 2023
da23cd9
Print anyway
brandonsturgeon Jun 19, 2023
bd933fc
wip
brandonsturgeon Jun 24, 2023
46d891d
Fully implement Range header
brandonsturgeon Jun 30, 2023
cb44110
Incr version, fix range header usage
brandonsturgeon Jun 30, 2023
5b236e2
Refine final chunk checking
brandonsturgeon Jun 30, 2023
c9f89b0
Fixes, cleanup
brandonsturgeon Jun 30, 2023
26bdb45
Change revision, print instead
brandonsturgeon Jun 30, 2023
6104db3
Increase default
brandonsturgeon Jun 30, 2023
0eee0e3
Header changes, new cache disable convar, debug prints
brandonsturgeon Jul 3, 2023
30ddea3
Add hacky fix for 404s
brandonsturgeon Jul 4, 2023
8e256af
Remove send delay
brandonsturgeon Jul 6, 2023
f1d89ab
WIP - raw text sending
brandonsturgeon Jul 7, 2023
0309ac1
Add timeout convar
brandonsturgeon Jul 17, 2023
c65aac6
Improve loading resilience, add HTTP override option
brandonsturgeon Jul 18, 2023
65e9a3b
Quiet print
brandonsturgeon Jul 19, 2023
8c72f32
Fix error call
brandonsturgeon Jul 20, 2023
5e00516
Allow disabling Ranges (#39)
brandonsturgeon Aug 1, 2023
8e6bbd5
Remove print
brandonsturgeon Sep 17, 2023
d607f2f
Get size on server, prevent duplicate sends
brandonsturgeon Sep 25, 2023
6d41bed
Small net fallback
brandonsturgeon Sep 27, 2023
61c8711
Remove prints - remove check
brandonsturgeon Sep 27, 2023
c64923f
Properly(?) handle physics objects
brandonsturgeon Nov 22, 2023
b9fdd99
Add clarification
brandonsturgeon Mar 5, 2024
bd44518
Fix missing cache key
brandonsturgeon Mar 11, 2024
c7c5463
Use SFS! (slight cleanup too)
brandonsturgeon May 23, 2024
0d370d1
Fix typo
brandonsturgeon May 24, 2024
3ea1fb8
add express.Seed (sv)
brandonsturgeon May 28, 2024
85b8614
Update sfs.lua
brandonsturgeon Aug 5, 2024
311beb7
Remove 404 retries, improve message about revision mismatch
brandonsturgeon Aug 22, 2024
6960736
Better error messages, hook on failure
brandonsturgeon Nov 12, 2024
bd7ae88
Add note about gmodexpress.com
brandonsturgeon Nov 12, 2024
aabbd2d
Add docs for express.Seed
brandonsturgeon Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ Doing it this way comes with a number of practical benefits:

Express works by storing the data you send on Cloudflare's Edge servers. Using Cloudflare workers, KV, and D1, Express can cheaply serve millions of requests and store hundreds of gigabytes per month. Cloudflare's Edge servers offer extremely low-latency requests and data access to every corner of the globe.

By default, Express uses [gmod.express](https://gmod.express), the public and free API provided by CFC Servers, but anyone can easily host their own!
By default, Express uses [gmod.express](https://gmod.express) , the public and free API provided by CFC Servers, but anyone can easily host their own!
Check out the [Express Service](https://github.com/CFC-Servers/gm_express_service) README for more information.

_(Note: [gmodexpress.com](https://gmodexpress.com) is an alias URL that might help if some clients get random HTTP failures to gmod.express)_

## Usage

<details>
Expand Down Expand Up @@ -350,6 +352,71 @@ end
```
</details>

<details>
<summary><h4> <strong><img src="https://user-images.githubusercontent.com/7936439/200705110-55b19d08-b342-4e94-a7c3-6b45baf98c2b.png" width="15"> <code>express.Seed( table data, function onSeeded )</code></strong> </h4></summary>

#### <ins>**Description**</ins>
"Seeds" the given data, meaning you won't need to upload it right when you need it.
This is useful if you generate data on server startup and need it available to download as soon as clients spawn in.

Technically, this works by saving the hash of the data to the express send cache, so when you try to send it again it'll hit the send cache.

#### <ins>**Arguments**</ins>
1. **`table data`**
- The table to send
- This table can be of any size, in any order, with nearly any data type.
2. **`function onSeeded( id string, hash string, niceSize string ) = nil`**
- Called when the data has been successfully seeded and is ready for clients to download
- This callback takes three parameters (you probably never need to read these):
- **`id string`**: The ID of the data in the express API
- **`hash string`**: The hash of the data
- **`niceSize string`**: A human-readable string of the data size

#### <ins>**Example**</ins>
Seed some data at startup and send it to players when they spawn.

This includes a lot of failsafe code that makes absolutely sure the data reaches the clients when it's ready.
Realistically, the data will probably upload so quickly that you don't need to worry about this.

```lua
-- Server
local dataIsReady = false
local pendingPlayers = {} -- In case players spawn before this data is ready

local bigDataSet = buildBigDataSet()
express.Seed( bigDataSet, function()
dataIsReady = true

-- Now that it's ready, send it to anyone who has been waiting for it
if #pendingPlayers > 0 then
express.Send( "big_data", bigDataSet, pendingPlayers )
pendingPlayers = nil
end
end )

hook.Add( "ExpressPlayerReceiver", "MyAddon_BigDataSender", function( ply, message )
if message ~= "big_data" then return end -- We only care about the receiver for our message

-- If we don't have the data ready yet (must be big!) then we'll send it to them when it's ready
if not dataIsReady then
table.insert( pendingPlayers, ply )
return
end

express.Send( "big_data", bigDataSet, ply )
end )


-- Client
hook.Add( "ExpressLoaded", "MyAddon_ReceiveBigData", function()
express.Receive( "big_data", function( data )
print( "I got the data :)" )
processData( data )
end )
end )
```
</details>

<details>
<summary><h3>:fishing_pole_and_fish: Hooks</h3></summary>

Expand Down
7 changes: 6 additions & 1 deletion lua/autorun/gm_express_init.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
AddCSLuaFile( "includes/modules/pon.lua" )
express = {}
function express.Receive()
error( "express.Receive called before Express has loaded! Try using the ExpressLoaded hook to know when it's safe" )
end

AddCSLuaFile( "includes/modules/sfs.lua" )
include( "gm_express/sh_init.lua" )
Loading
Loading