npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kratos-server

v1.5.0

Published

Collect and stream chunked files over http and stream them into Google Cloud Storage

Downloads

17

Readme

kratos

 __                   __
|  | ______________ _/  |_  ____  ______
|  |/ /\_  __ \__  \\   __\/  _ \/  ___/
|    <  |  | \// __ \|  | (  <_> )___ \
|__|_ \ |__|  (____  /__|  \____/____  >
     \/            \/                \/

What

Collect and stream chunked files over http and stream them into Google Cloud Storage.

How

You will need two services, a running instance of this one and a client implementation, which basically requires an HTTP server with 3 endpoints. You can find a sample client implementation in Java here.

Each transfer is handled in a "transaction" you can request such by calling the POST: /api/transaction/run (as mentioned below). The service will then open up a stream to the GCS file (filename will be the transactinId) in the configured bucket, it will afterwards walk through all the provided chunks e.g. chunks: 2, will result in 3 calls /request/{transactionId}/chunk/0, /request/{transactionId}/chunk/1 and /request/{transactionId}/chunk/2 while streaming the response into the GCS file. During start and end of such transactions the /start and /ack endpoints will be called in the service provider.

The service can handle multiple transactions at the same time, calling the endpoint POST: /api/transaction/run with the same transactionId again, will trigger no actions whatsoever, if the transaction is still running.

Requirements

  • Node.js >= 9.x.x (we suggest >= 11.x.x)

Install

As simple as yarn global add kratos-server.

(NOTE: In case you dont have yarn run npm i -g yarn first.)

Run

kratos-server "./baseConfig.js"

You just have to throw in a config (JSON or JS). A base config is always used, so you just have to overwrite your specific requirements.

Check out kratos-server -h for other options.

Using

With any HTTP client.

Checkout the API quick start or the setup infos below.

API Quick Start

Basically there are two available api endpoints, POST: /api/transaction/run to run a transaction and GET: /api/transaction/status to check all currently running transactions.

Triggering a sample transaction might look like this:

curl -X POST \
  http://localhost:1919/api/transaction/run \
  -H 'Content-Type: application/json' \
  -d '{
	"transactionId": "blablabla",
	"chunks": 3,
	"baseUrl": "http://localhost:8080",
	"extension": "parquet",
	"contentType": "application/octet-stream"
}'

Setup Info

Metrics

You can monitor this service via Prometheus at /metrics.

Access Management

This service has build in access management. You define tokens as keys in the configs http access object and set the topic names or special rights as string members of the key's array value. A wildcard * grants all rights.

e.g.

const config = {
  http: {
    access: {
      "token-for-admin": [ "*" ],
      "other-token": "*",
    },
  },
};

When making calls to the HTTP API the token is provided in the authorization header.

  • * Allows every operation

Be aware that the default configuration is a wildcard for everything. (Meaning no token is required). Never expose this service's HTTP interface publicly.

Config via Environment Variables

It is possible to set a few config parameters (most in role of secrets) via environment variables. They will always overwrite the passed configuration file.

  • ACL_DEFINITIONS="mytoken=topic1,topic2;othertoken=topic3" roach-storm -l "./config.json" -> turns into: config.http.access.mytoken = [ "topic1", "topic2" ];

Maintainer

Christian Fröhlingsdorf @chrisfroeh

Build with :heart: :pizza: and :coffee: in cologne.