Commit 824c9469 authored by Tobinsk's avatar Tobinsk
Browse files

Merge branch 'readme' into 'master'


See merge request !7
parents 787d5acc ca8a17e7
# linker
The linker is a [kafka sink]( for the [neo4j]( graph database. It consumes messages from the `linker` topic and writes them to the database.
## Neo4jStreamWriter
The Neo4jStreamWriter consumes a stream of kafka messages and writes the content of the message to the database. It is very simple and can handle backpressure.
## Docker
To build the image use the following command. The container is based on the [histub/ node-kafka-docker-base](
docker build -t .
# Upload to the registry
docker push
## CD
We have a build pipeline in gitlab. So manual building of the image is no longer necessary.
## Deploy to k8
This streaming app is part of the [deploy geolinker helm chart](
import {v1 as neo4j} from 'neo4j-driver';
import * as jsesc from 'jsesc';
export class Linker {
private nconf;
private logger;
private driver;
private uriBuilder;
constructor(nconf, logger, uriBuilder) {
this.nconf = nconf;
this.logger = logger;
this.uriBuilder = uriBuilder;
this.driver = neo4j.driver(
* Create a new node in the db if they do not exists
* @param node
* @returns {Result}
public newNode(node) {
// todo: from topic!
const provider = 'geonames';
const uri = this.uriBuilder.geoname(;
return this.driver.session().run(`MERGE (n:Place { uri: '${uri}'})
ON CREATE SET '${}', n.provider: ${provider}
ON MATCH SET '${}', n.provider: ${provider}`);
* Write connection int the db. Create nodes if they do not exists
* @param connection
public connect(connection) {
return new Promise( (resolve, reject) => {
let query = `MERGE (o:Place {uri:'${connection.from}'}) `;, i) => {
query += ` MERGE (t${i}:Place {uri:'${current}'}) `;
query += ` MERGE (o)-[:${connection.relation.type} {author:'${}'}]->(t${i}) `;
// get a new session'Try to get a session');;
const session = this.driver.session();'Try to build network'); => {
}).catch((err) => {
setTimeout(() => {
reject(`Error while saving a connection to neo4j ${JSON.stringify(err)}`);
}, 1000);
* There is no build in function to escape
* @param string
public escape(data: string) {
return jsesc(data);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment