@@ -6,39 +6,6 @@ import {getDatabase, PROJECT_ID} from "../utils/rtdb";
6
6
import { Game } from "../models/Game" ;
7
7
const logger = functions . logger ;
8
8
9
- /*const getNextRTDBInstanceNum = async (): Promise<number> => {
10
- const res = await axios.get(`https://firebasedatabase.googleapis.com/v1beta/projects/${PROJECT_ID}/locations/-/instances?pageSize=100`, {
11
- headers: {
12
- 'Authorization': `Bearer `,
13
- },
14
- })
15
- const instances = res.data.instances as any[];
16
- return instances.length;
17
- }
18
-
19
- const createRTDBInstance = async (databaseId: string) => {
20
- await axios.get(`https://firebasedatabase.googleapis.com/v1beta/projects/${PROJECT_ID}/locations/${RTDB_LOCATION}/instances?database_id=${databaseId}`, {
21
- headers: {
22
- 'Authorization': `Bearer `,
23
- },
24
- })
25
- }
26
-
27
- const createNewRTDBInstance = async () => {
28
- const nextNum = await getNextRTDBInstanceNum();
29
- const newRTDBInstanceName = getRTDBInstanceName(nextNum);
30
- await createRTDBInstance(newRTDBInstanceName);
31
- await db.collection(FirebaseCollection.RTDBInstances).doc(newRTDBInstanceName).set({
32
- createdAt: FieldValue.serverTimestamp(),
33
- connectionsCount: 0,
34
- } as RTDBInstance)
35
- admin.app().database(`https://secondary_db_url.firebaseio.com`)
36
-
37
- return newRTDBInstanceName;
38
- }
39
-
40
- */
41
-
42
9
/**
43
10
* API to effectively balance the game load by selected the best RTDB instance, in terms of minimum number connections (tabs, browsers, devices, ...).
44
11
* It needs a "gameId" as url parameter and can be called only by authenticated users.
0 commit comments