Git Product home page Git Product logo

splunk-persistentconn's Introduction

splunk-persistentconn

GoDoc

splunk-persistentconn implements the protocol that splunk core uses to communicate with persistent script that's used to power REST endpoints of an app

How to use

Usage example:

package main

import (
    "fmt"
    "net/http"
    "time"

    conn "github.com/DrakeW/splunk-persistentconn"
)

func main() {
    // server initialization
    server := conn.NewServer()

    // register endpoint using either static path or path pattern
    server.Handle("entity/:id/data", func(req conn.Request) (conn.Response, error) {
        return conn.Response{
            StatusCode: http.StatusOK,
            Body:       fmt.Sprintf("hello world %s", req.Params["id"]),
        }, nil
    }, "GET", "POST")

    // starts server
    server.Run()
}

An example app is located in the examples directory.

Performance

This package is built to take advantage of the concurrent processing capability provided by goroutines for each handler registered. However, since Splunk core sends requests to the server process in a synchronous manner, only one goroutine is spawned at a time therefore currently there's no performance boost.

Based on rough benchmark with the same 5000 non-blocking requests (where each request takes ~0.5s to finish) hitting both the python REST endpoint based on PersistentServerConnectionApplication and the Go REST endpoint using the splunk-persistentconn package, performance is roughly the same.

Disclaimer

This package is not officially supported by Splunk. Please use with caution and feel free to open issue or PR for any kind of bug report or feature enhancement.

splunk-persistentconn's People

Contributors

junyu-w avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

frankfanslc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.