blob: 19c75c98adedfbda45e21de0d451b1a2e744a11d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
import autobind from 'autobind-decorator';
import Chart, { KVs } from '../core';
import { Instances } from '@/models/index';
import { name, schema } from './entities/federation';
/**
* フェデレーションに関するチャート
*/
// eslint-disable-next-line import/no-default-export
export default class FederationChart extends Chart<typeof schema> {
constructor() {
super(name, schema);
}
@autobind
protected async queryCurrentState(): Promise<Partial<KVs<typeof schema>>> {
const [total] = await Promise.all([
Instances.count({}),
]);
return {
'instance.total': total,
};
}
@autobind
public async update(isAdditional: boolean): Promise<void> {
await this.commit({
'instance.total': isAdditional ? 1 : -1,
'instance.inc': isAdditional ? 1 : 0,
'instance.dec': isAdditional ? 0 : 1,
});
}
@autobind
public async deliverd(host: string, succeeded: boolean): Promise<void> {
await this.commit(succeeded ? {
'deliveredInstances': [host],
} : {
'stalled': [host],
});
}
@autobind
public async inbox(host: string): Promise<void> {
await this.commit({
'inboxInstances': [host],
});
}
}
|