clickhousegraphqlgo

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2021 License: MIT Imports: 9 Imported by: 0

README

clickhouse-graphql-go

GraphQL implementation for clickhouse in Go. This package stores real time streaming websocket data in clickhouse and uses GraphQL to consume the same.

Installation

go get github.com/ranjanrak/clickhouse-graphql-go

Usage

import (
    clickhousegraphqlgo "github.com/ranjanrak/clickhouse-graphql-go"
)

// Dump tick websocket data to clickhouse
// Pass list of instrument token for subscription to websocket feeds
clickhousegraphqlgo.ClickhouseDump([]uint32{779521, 256265, 1893123, 13209858})

// Run graphql server on clickhouse
clickhousegraphqlgo.GraphqlServer()

GraphQL query
query {
  Tick(instrument_token:1893123) {
    instrument_token
    timestamp
    lastprice
    volumetraded
    oi
  }
}

Response

{
  "data": {
    "Tick": {
      "instrument_token": 1893123,
      "lastprice": 74.245,
      "oi": 1990638,
      "timestamp": "2021-08-24T16:38:39+05:30",
      "volumetraded": 1099802
    }
  }
}
Sample query on graphiQL

graphQL_dash

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClickhouseDump

func ClickhouseDump(tokens []uint32)

func GraphqlServer

func GraphqlServer()

func SetDB

func SetDB()

Types

type TickData

type TickData struct {
	InstrumentToken int
	Timestamp       time.Time
	LastPrice       float64
	VolumeTraded    int
	OI              int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL