mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Add vertex reference to pipeline statement classes. (#19134)
This commit is contained in:
parent
0b03166d2d
commit
748d152354
5 changed files with 37 additions and 25 deletions
|
@ -8,6 +8,7 @@ import expect from 'expect.js';
|
|||
import { Statement } from '../statement';
|
||||
|
||||
describe('Statement class', () => {
|
||||
let vertex;
|
||||
let meta;
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -18,21 +19,25 @@ describe('Statement class', () => {
|
|||
password: 'password'
|
||||
}
|
||||
};
|
||||
vertex = {
|
||||
meta,
|
||||
id: 'statement_id',
|
||||
hasExplicitId: true,
|
||||
stats: { }
|
||||
};
|
||||
});
|
||||
|
||||
describe('Statement from constructor', () => {
|
||||
it('creates a new Statement instance', () => {
|
||||
const statement = new Statement(
|
||||
'statement_id',
|
||||
true,
|
||||
{},
|
||||
meta
|
||||
vertex
|
||||
);
|
||||
|
||||
expect(statement.id).to.be('statement_id');
|
||||
expect(statement.hasExplicitId).to.be(true);
|
||||
expect(statement.stats).to.eql({});
|
||||
expect(statement.meta).to.equal(meta);
|
||||
expect(statement.vertex).to.eql(vertex);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,10 +9,12 @@ import { makeStatement } from './make_statement';
|
|||
import { isVertexPipelineStage } from './utils';
|
||||
|
||||
export class IfStatement extends Statement {
|
||||
constructor(id, hasExplicitId, stats, meta, condition, trueStatements, elseStatements) {
|
||||
super(id, hasExplicitId, stats, meta);
|
||||
constructor(vertex, trueStatements, elseStatements) {
|
||||
super(vertex);
|
||||
|
||||
this.condition = condition;
|
||||
const { name } = vertex;
|
||||
|
||||
this.condition = name;
|
||||
this.trueStatements = trueStatements;
|
||||
this.elseStatements = elseStatements;
|
||||
}
|
||||
|
@ -38,11 +40,7 @@ export class IfStatement extends Statement {
|
|||
}
|
||||
|
||||
return new IfStatement(
|
||||
ifVertex.id,
|
||||
ifVertex.hasExplicitId,
|
||||
ifVertex.stats,
|
||||
ifVertex.meta,
|
||||
ifVertex.name,
|
||||
ifVertex,
|
||||
trueStatements,
|
||||
elseStatements
|
||||
);
|
||||
|
|
|
@ -7,20 +7,21 @@
|
|||
import { Statement } from './statement';
|
||||
|
||||
export class PluginStatement extends Statement {
|
||||
constructor(id, hasExplicitId, stats, meta, pluginType, name) {
|
||||
super(id, hasExplicitId, stats, meta);
|
||||
constructor(vertex) {
|
||||
super(vertex);
|
||||
|
||||
const {
|
||||
pluginType,
|
||||
name
|
||||
} = vertex;
|
||||
|
||||
this.pluginType = pluginType; // input, filter, or output
|
||||
this.name = name; // twitter, grok, elasticsearch, etc.
|
||||
}
|
||||
|
||||
static fromPipelineGraphVertex(pluginVertex) {
|
||||
return new PluginStatement(
|
||||
pluginVertex.id,
|
||||
pluginVertex.hasExplicitId,
|
||||
pluginVertex.stats,
|
||||
pluginVertex.meta,
|
||||
pluginVertex.pluginType,
|
||||
pluginVertex.name
|
||||
pluginVertex
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,10 +9,7 @@ import { Statement } from './statement';
|
|||
export class Queue extends Statement {
|
||||
static fromPipelineGraphVertex(queueVertex) {
|
||||
return new Queue(
|
||||
queueVertex.id,
|
||||
queueVertex.hasExplicitId,
|
||||
queueVertex.stats,
|
||||
queueVertex.meta
|
||||
queueVertex
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,21 @@
|
|||
*/
|
||||
|
||||
export class Statement {
|
||||
constructor(id, hasExplicitId, stats, meta) {
|
||||
constructor(vertex) {
|
||||
const {
|
||||
id,
|
||||
hasExplicitId,
|
||||
stats,
|
||||
meta
|
||||
} = vertex;
|
||||
|
||||
this.id = id;
|
||||
this.hasExplicitId = hasExplicitId;
|
||||
this.stats = stats;
|
||||
this.meta = meta;
|
||||
|
||||
// storing a direct reference to the source vertex is convenient
|
||||
// for interoperability with components that use the existing graph
|
||||
this.vertex = vertex;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue