httpstream provides HTTP handlers for simultaneous streaming uploads and downloads of objects, as well as persistence and a standalone server.

Related tags

Network httpfstream
Overview

httpfstream

httpfstream provides HTTP handlers for simultaneous streaming uploads and downloads of files, as well as persistence and a standalone server.

It allows a writer to APPEND data to a resource via a WebSocket and multiple readers to FOLLOW updates to the resource using WebSockets.

Only one simultaneous appender is allowed for each resource. If there are no appenders at an existing resource, the server returns the full data in an HTTP 200 (bypassing WebSockets) to a follower. If the resource has never been written to, the server responds to a follower with HTTP 404.

Build Status xrefs funcs top func library users status Views in the last 24 hours

Installation

go get github.com/sourcegraph/httpfstream

Usage

httpfstream supports 2 modes of usage: as a standalone server or as a Go library.

As a standalone server

The command httpfstream-server launches a server that allows clients to APPEND and FOLLOW arbitrary file paths. Run with -h for more information.

For example, first install the commands:

$ go get github.com/sourcegraph/httpfstream/cmd/...

Then run the server with:

$ httpfstream-server -root=/tmp/httpfstream -http=:8080

Then launch a follower on /foo.txt:

$ httpfstream-follow -v http://localhost:8080/foo.txt
# keep this terminal window open

And start appending to /foo.txt in a separate terminal:

$ httpfstream-append -v http://localhost:8080/foo.txt
# start typing:
foo
bar
baz
# now exit: ctrl-C

Notice that the httpfstream-follow window echoes what you type into the appender window. Once you close the appender, the follower quits as well.

As a Go library

Server

The function httpfstream.New(root string) takes the root file storage path as a parameter and returns an http.Handler that lets clients APPEND and FOLLOW to paths it handles.

The file cmd/httpfstream-server/server.go contains a full example, summarized here:

package main

import (
	"github.com/sourcegraph/httpfstream"
	"log"
	"net/http"
	"os"
)

func main() {
	h := httpfstream.New("/tmp/httpfstream")
	h.Log = log.New(os.Stderr, "", 0)
	http.Handle("/", h)

	err := http.ListenAndServe(":8080", nil)
	if err != nil {
		log.Fatalf("ListenAndServe: %s", err)
	}
}

Appender

Clients can append data to a resource using either httpfstream.Append(u *url.URL, r io.Reader) error (if they already have an io.Reader) or httpfstream.OpenAppend(u *url.URL) (io.WriteCloser, error).

Click on the function names (linked above) to see full docs and usage examples on Sourcegraph.

Follower

Clients can follow a resource's data using httpfstream.Follow(u *url.URL) (io.ReadCloser, error).

Click on the function names (linked above) to see full docs and usage examples on Sourcegraph.

Contributing

Patches and bug reports welcomed! Report issues and submit pull requests using GitHub.

You might also like...
Standalone client for proxies of Opera VPN

opera-proxy Standalone Opera VPN client. Younger brother of hola-proxy. Just run it and it'll start a plain HTTP proxy server forwarding traffic throu

Standalone client for proxies of Windscribe browser extension

windscribe-proxy Standalone Windscribe proxy client. Younger brother of opera-proxy. Just run it and it'll start a plain HTTP proxy server forwarding

A standalone ipfs gateway

rainbow Because ipfs should just work like unicorns and rainbows Building go build Running rainbow Configuration NAME: rainbow - a standalone ipf

Implementing SPEEDEX price computation engine in Golang as a standalone binary that exchanges can call

speedex-standalone Implementing SPEEDEX price computation engine in Golang as a standalone binary that exchanges can call. Notes from Geoff About Tato

Scout is a standalone open source software solution for DIY video security.
Scout is a standalone open source software solution for DIY video security.

scout Scout is a standalone open source software solution for DIY video security. https://www.jonoton-innovation.com Features No monthly fees! Easy In

Hybridnet is an open source container networking solution, integrated with Kubernetes and used officially by following well-known PaaS platforms

Hybridnet What is Hybridnet? Hybridnet is an open source container networking solution, integrated with Kubernetes and used officially by following we

Nuke-Net is a VERY VERY over powered and ridiculous web crawler that is well- very very noisy XD read more here
Nuke-Net is a VERY VERY over powered and ridiculous web crawler that is well- very very noisy XD read more here

Nuke-Net is a VERY VERY over powered and ridiculous web crawler that is well- very very noisy XD read more here

Owner
Sourcegraph
Code search and navigation for teams (self-hosted, OSS)
Sourcegraph
Go library for writing standalone Map/Reduce jobs or for use with Hadoop's streaming protocol

dmrgo is a Go library for writing map/reduce jobs. It can be used with Hadoop's streaming protocol, but also includes a standalone map/reduce impleme

Damian Gryski 103 Nov 27, 2022
A standalone Web Server developed with the standard http library, suport reverse proxy & flexible configuration

paddy 简介 paddy是一款单进程的独立运行的web server,基于golang的标准库net/http实现。 paddy提供以下功能: 直接配置http响应 目录文件服务器 proxy_pass代理 http反向代理 支持请求和响应插件 部署 编译 $ go build ./main/p

fangyousong 5 Oct 18, 2022
Tapestry is an underlying distributed object location and retrieval system (DOLR) which can be used to store and locate objects. This distributed system provides an interface for storing and retrieving key-value pairs.

Tapestry This project implements Tapestry, an underlying distributed object location and retrieval system (DOLR) which can be used to store and locate

Han Cai 1 Mar 16, 2022
Downloads the Windows 10 wallpapers provided by Microsoft.

microsoft-wallpapers Preparation Prepare an input file that contains a list of links from the Microsoft website that lead to wallpapers. This list is

River Wooley 0 Nov 29, 2021
Videos2gether-server - Server for the Realtime video streaming app Videos2Gether

Videos Together server Server source code for the https://videos2gether.com Arch

Tiago Taquelim 0 Jan 9, 2022
Bell is the simplest event system written in Go (Golang) which is based on the execution of handlers independent of the main channel.

Bell Bell is the simplest event system written in Go (Golang) which is based on the execution of handlers independent of the main channel. Written in

NUT.Tech 29 Nov 17, 2022
Http-server - A HTTP server and can be accessed via TLS and non-TLS mode

Application server.go runs a HTTP/HTTPS server on the port 9090. It gives you 4

Vedant Pareek 0 Feb 3, 2022
This package helps establish a websocket connection to the bilibili streaming server.

biliStreamClient This package helps establish a websocket connection to the bilibili streaming server. bilibili直播弹幕的WebSocket协议分析请参考:https://blog.csdn

JINGWEI ZHANG 24 Oct 25, 2022
PinGo is a standalone and feature-rich tool for common IP-based reachability checking tasks. Ping or Trace and Observe in real-time the statistics.

pingo As a network champion from designing and implementing to troubleshooting large scale networks - I know that is usually not easy for administrato

Jerome Amon 3 Sep 26, 2022
A simple, standalone, and lightWeight tool that can do health/status checking, written in Go.

EaseProbe EaseProbe is a simple, standalone, and lightWeight tool that can do health/status checking, written in Go. Table of Contents EaseProbe 1. Ov

MegaEase 1.4k Dec 24, 2022