@andrew_l/binlog 0.3.22 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +99 -101
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +211 -311
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -9
- package/dist/index.cjs +0 -326
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -123
- package/dist/index.d.ts +0 -123
package/dist/index.d.mts
CHANGED
|
@@ -1,51 +1,50 @@
|
|
|
1
|
-
import { Structure } from
|
|
2
|
-
|
|
1
|
+
import { Structure } from "@andrew_l/tl-pack";
|
|
3
2
|
/**
|
|
4
3
|
* Options for configuring the KdbBinlog
|
|
5
4
|
*/
|
|
6
5
|
interface BinlogOptions {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
/**
|
|
7
|
+
* File location to store binlog files
|
|
8
|
+
* @default './binlogs/log-{index}.bin'
|
|
9
|
+
*/
|
|
10
|
+
path: string;
|
|
11
|
+
/**
|
|
12
|
+
* Maximum size of each binlog file before rotation (in bytes)
|
|
13
|
+
* @default 104857600
|
|
14
|
+
*/
|
|
15
|
+
maxFileSize: number;
|
|
16
|
+
/**
|
|
17
|
+
* Whether to enable log rotation
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
rotation: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to sync writes to disk immediately
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
syncWrites: boolean;
|
|
26
|
+
structures?: Structure.Constructor[];
|
|
28
27
|
}
|
|
29
28
|
/**
|
|
30
29
|
* Represents a single binlog entry
|
|
31
30
|
*/
|
|
32
31
|
interface BinlogEntry<TData = Buffer> {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Operation code defining the type of operation
|
|
34
|
+
*/
|
|
35
|
+
opcode: number;
|
|
36
|
+
/**
|
|
37
|
+
* Unix timestamp when the entry was created
|
|
38
|
+
*/
|
|
39
|
+
timestamp: number;
|
|
40
|
+
/**
|
|
41
|
+
* Binary data of the entry
|
|
42
|
+
*/
|
|
43
|
+
data: TData | Buffer;
|
|
44
|
+
/**
|
|
45
|
+
* Position in the file where this entry starts
|
|
46
|
+
*/
|
|
47
|
+
position: number;
|
|
49
48
|
}
|
|
50
49
|
/**
|
|
51
50
|
* TypeScript implementation of binlog system
|
|
@@ -53,71 +52,70 @@ interface BinlogEntry<TData = Buffer> {
|
|
|
53
52
|
* @group Main
|
|
54
53
|
*/
|
|
55
54
|
declare class Binlog {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
55
|
+
#private;
|
|
56
|
+
private _options;
|
|
57
|
+
private _filePattern;
|
|
58
|
+
private _directory;
|
|
59
|
+
private _currentFile;
|
|
60
|
+
private _currentFileDescriptor;
|
|
61
|
+
private _currentFileSize;
|
|
62
|
+
private _currentFileIndex;
|
|
63
|
+
private _isOpen;
|
|
64
|
+
private _log;
|
|
65
|
+
private readonly BINLOG_MAGIC;
|
|
66
|
+
private readonly BINLOG_VERSION;
|
|
67
|
+
private readonly BINLOG_HEADER_SIZE;
|
|
68
|
+
private readonly BINLOG_ENTRY_HEADER_SIZE;
|
|
69
|
+
private readonly BINLOG_FLAG;
|
|
70
|
+
constructor(options: BinlogOptions);
|
|
71
|
+
/**
|
|
72
|
+
* Initialize the binlog system, ensuring directory exists and pick most recent binlog file
|
|
73
|
+
* @returns Promise resolving to true if successful, false otherwise
|
|
74
|
+
*/
|
|
75
|
+
init(): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Open the binlog for writing
|
|
78
|
+
*/
|
|
79
|
+
open(): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Close the current binlog file
|
|
82
|
+
*/
|
|
83
|
+
close(): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Write a binlog entry
|
|
86
|
+
* @param opcode - Operation code
|
|
87
|
+
* @param data - Data to write
|
|
88
|
+
* @returns Promise resolving to true if successful, false otherwise
|
|
89
|
+
*/
|
|
90
|
+
write(opcode: number, data: unknown): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Rotate the binlog file
|
|
93
|
+
*/
|
|
94
|
+
rotate(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Read and parse all entries from a binlog file
|
|
97
|
+
* @param filename - Binlog file to read
|
|
98
|
+
* @param unsafe - Ignore broken binlog records otherwise throws error
|
|
99
|
+
* @returns Array of parsed entries
|
|
100
|
+
*/
|
|
101
|
+
readEntries<TData = Buffer>(filename: string, unsafe?: boolean): Promise<BinlogEntry<TData>[]>;
|
|
102
|
+
/**
|
|
103
|
+
* Get the current binlog file index
|
|
104
|
+
*/
|
|
105
|
+
get currentFileIndex(): number;
|
|
106
|
+
/**
|
|
107
|
+
* Get current binlog file name
|
|
108
|
+
*/
|
|
109
|
+
get currentFileName(): string;
|
|
110
|
+
/**
|
|
111
|
+
* Get current binlog directory
|
|
112
|
+
*/
|
|
113
|
+
get directory(): string;
|
|
115
114
|
}
|
|
116
|
-
|
|
117
115
|
/**
|
|
118
116
|
* Create binlog instance
|
|
119
117
|
* @group Main
|
|
120
118
|
*/
|
|
121
119
|
declare function createBinlog(options: Partial<BinlogOptions>): Binlog;
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
export { Binlog, BinlogEntry, BinlogOptions, createBinlog };
|
|
121
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["path","maxFileSize","rotation","syncWrites","structures","Structure","Constructor","TData","Buffer","opcode","timestamp","data","position","private","_options","_filePattern","_directory","_currentFile","_currentFileDescriptor","_currentFileSize","_currentFileIndex","_isOpen","_log","BINLOG_MAGIC","BINLOG_VERSION","BINLOG_HEADER_SIZE","BINLOG_ENTRY_HEADER_SIZE","BINLOG_FLAG","constructor","BinlogOptions","options","init","Promise","open","close","write","rotate","readEntries","filename","unsafe","BinlogEntry","currentFileIndex","currentFileName","directory","Partial","BinlogOptions","options","Binlog"],"sources":["../src/Binlog.d.ts","../src/index.d.ts"],"mappings":";;AAIA;;UAAiB,aAAA;EAqBqB;;;;EAhBlCA,IAAAA;EAgB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