Socket
Book a DemoInstallSign in
Socket

griffon-client

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

griffon-client

Griffon client

0.1.3
latest
npmnpm
Version published
Maintainers
1
Created
Source

Griffon Client

A NodeJS Client for Griffon workflows.

Griffon is a message queue for easily building workflows. A griffon server acts a hub, connecting griffon clients. Clients connect and kickoff tasks within a workflow, then relay the results when they are done. Griffon tracks dependecies as clients connect, and provides a powerful architecture for developing against, debugging, and running complex workflows.

Getting Started

Prerequisites

Griffon clients require a running Griffon server, see installing and running a Griffon Server. It's a snap to set up.

Installing

npm install griffon-client

Running

The following is a simple example of useage

const griffon = require('griffon-client')


const operator = await griffon.connect({
    uri: 'http://localhost:3001',
    environment: 'local',
    operator: 'test',
    produce: ['topic1', 'topic2'],
    consume: ['topic1', 'topic2'],
})

operator.consume('topic1', async task => {
    console.log(task)
    await task.produce({
        topic: 'topic2',
        data: 'World'
    })
})

operator.consume('topic2', async task => {
    console.log(task)
})


await operation.produce({
    topic: 'topic1',
    data: 'Hello'
})

The following is a complete example:

const griffon = require('griffon-client')


const operator = await griffon.connect({
    uri: 'http://localhost:3001',
    username: 'admin',
    password: 'password',
    environment: 'local',
    operator: 'test1',
    channels: ['.*'],
    consume: {and: ['topic1', 'topic2']},
    produce: ['topic3', 'topic4'],
})

operator.consume(async operation => {

    console.log(operation)

    const output = operation.data.topic1.toUpperCase() + operation.data.topic2.toLowerCase()

    console.log(output)

    await operation.produce({
        topic: 'topic3',
        data: output + 3
    })

    await operation.produce({
        topic: 'topic4',
        data: output + 4
    })
})


setTimeout(async () => {

    const operator = await griffon.connect({
        uri: 'http://localhost:3001',
        username: 'admin',
        password: 'password',
        environment: 'local2',
        consume: {and: ['topic1', 'topic2']},
        channels: ['dev'],
        operator: 'test1',
        produce: ['topic3', 'topic4'],
    })

    operator.consume(async operation => {

        console.log(operation)

        const output = operation.data.topic1.toUpperCase() + operation.data.topic2.toLowerCase()

        console.log(output)

        await operation.produce({
            topic: 'topic3',
            data: output + 3
        })

        await operation.produce({
            topic: 'topic4',
            data: output + 4
        })
    })

}, 2000)

FAQs

Package last updated on 07 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.