/** * @pwngh/economy-lab * * Copyright (c) Preston Neal * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ interface MysqlConnection { query(sql: string, params?: ReadonlyArray): Promise<[unknown, unknown]>; release(): void; } /** * The pool seam `mysqlStore` rides, declared structurally: the seam is a shape, not a name, so * `mysqlStore` accepts any pool with these three members — the `mysql2` pool `createMysqlPool` * builds, or the `mariadb` pool {@link createMariadbPool} builds here. `query` resolves a tuple * whose first slot holds rows for a SELECT or an affected-rows header for a write. */ export interface MysqlPool { query(sql: string, params?: ReadonlyArray): Promise<[unknown, unknown]>; getConnection(): Promise; end(): Promise; } /** * Create a {@link MysqlPool} from a connection URL using the `mariadb` driver — the * pipelining-capable opt-in behind the same seam `createMysqlPool` fills with `mysql2`. Same * store, same schema, same SQL: hand the pool to `mysqlStore` and every statement above the seam * is identical. The difference is the wire: mysql2's command queue holds one command in flight * per connection, while mariadb writes the next command before the previous response returns. * * Matches the mysql2 pool's configuration: big integer and decimal columns come back as exact * strings (the engine converts them to bigint), and the connection collation is pinned to the * schema's utf8mb4 default. `connectionLimit` caps the pool exactly as on `createMysqlPool` and * defaults to 10; each in-flight transaction holds one connection, so size it to at least the * number of concurrent submits. The URL must carry no query parameters — this factory maps the * URL to driver config by hand and throws rather than silently drop options mysql2 would honor. * * @example * import { createMariadbPool } from '@pwngh/economy-lab/engines/mysql-mariadb'; * import { mysqlStore } from '@pwngh/economy-lab/engines/mysql'; * * const pool = await createMariadbPool('mysql://econ:secret@127.0.0.1:3306/economy', { * connectionLimit: 32, * }); * const store = mysqlStore({ pool, schema: 'assert' }); */ export declare function createMariadbPool(url: string, options?: { connectionLimit?: number; }): Promise; export {};