mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
Optionally enable websocket compression
This commit is contained in:
parent
c6cabb8c75
commit
2b919c4eb0
3 changed files with 14 additions and 0 deletions
|
@ -421,3 +421,7 @@ checkActivityPubGetSignature: false
|
|||
# How long to save each log entry before deleting it.
|
||||
# Default: 2592000000 (1 week)
|
||||
#maxAge: 2592000000
|
||||
|
||||
# Transparently compress every websocket message on clients that support it.
|
||||
# Trades server CPU usage for reduced bandwidth usage and a faster frontend on the client.
|
||||
websocketCompression: false
|
||||
|
|
|
@ -136,6 +136,8 @@ type Source = {
|
|||
preSave?: boolean;
|
||||
maxAge?: number;
|
||||
};
|
||||
|
||||
websocketCompression?: boolean;
|
||||
};
|
||||
|
||||
export type Config = {
|
||||
|
@ -252,6 +254,8 @@ export type Config = {
|
|||
preSave: boolean;
|
||||
maxAge: number;
|
||||
};
|
||||
|
||||
websocketCompression?: boolean;
|
||||
};
|
||||
|
||||
export type FulltextSearchProvider = 'sqlLike' | 'sqlPgroonga' | 'meilisearch' | 'sqlTsvector';
|
||||
|
@ -400,6 +404,7 @@ export function loadConfig(): Config {
|
|||
preSave: config.activityLogging?.preSave ?? false,
|
||||
maxAge: config.activityLogging?.maxAge ?? (1000 * 60 * 60 * 24 * 30),
|
||||
},
|
||||
websocketCompression: config.websocketCompression,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import MainStreamConnection from './stream/Connection.js';
|
|||
import { ChannelsService } from './stream/ChannelsService.js';
|
||||
import type * as http from 'node:http';
|
||||
import type { IEndpointMeta } from './endpoints.js';
|
||||
import type {Config} from "@/config.js";
|
||||
|
||||
@Injectable()
|
||||
export class StreamingApiServerService {
|
||||
|
@ -49,6 +50,9 @@ export class StreamingApiServerService {
|
|||
private channelFollowingService: ChannelFollowingService,
|
||||
private rateLimiterService: SkRateLimiterService,
|
||||
private loggerService: LoggerService,
|
||||
|
||||
@Inject(DI.config)
|
||||
private config: Config,
|
||||
) {
|
||||
}
|
||||
|
||||
|
@ -74,6 +78,7 @@ export class StreamingApiServerService {
|
|||
public attach(server: http.Server): void {
|
||||
this.#wss = new WebSocket.WebSocketServer({
|
||||
noServer: true,
|
||||
perMessageDeflate: this.config.websocketCompression ?? false,
|
||||
});
|
||||
|
||||
server.on('upgrade', async (request, socket, head) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue