zipgoserve

package module
v0.0.0-...-71573ce Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: BSD-2-Clause Imports: 11 Imported by: 0

README

zipgoserve

Very simple implementation for serving static file content from of ZIP archive. Serves compressed content without decompression where possible. Assumes only deflate or store methods used in archive (e.g. standard linux zip utility)

Benchmark

** SIEGE 4.0.4
** Preparing 25 concurrent users for battle.
The server is now under siege...
Lifting the server siege...
Transactions:		      817585 hits
Availability:		      100.00 %
Elapsed time:		       59.93 secs
Data transferred:	    14293.70 MB
Response time:		        0.00 secs
Transaction rate:	    13642.33 trans/sec
Throughput:		      238.51 MB/sec
Concurrency:		       23.98
Successful transactions:      817585
Failed transactions:	           0
Longest transaction:	        0.06
Shortest transaction:	        0.00

TO DO

  • Check if mutex is needed for zip file access (implement as option ✔)
  • Benchmark results ✔
  • Preload small files to bytes slice (performance optimisation) ✔
  • ZIP file as example
  • Dockerization example
  • JSON mime maping example

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MIMEMap

type MIMEMap struct {
	Suffix string
	MIME   string
}

func HardcodedMap

func HardcodedMap() []MIMEMap

type ZipFileServer

type ZipFileServer struct {
	HTTPprefix       string
	IndexSuffix      string
	PATHprefix       string // html/
	CachingThreshold int64
	Mime             []MIMEMap
	Locker           *sync.Mutex // Looks like zip is concurrent read safe - locking removed
	// contains filtered or unexported fields
}

func (*ZipFileServer) AttachFile

func (zf *ZipFileServer) AttachFile(fn string)

func (*ZipFileServer) Close

func (zf *ZipFileServer) Close() error

func (*ZipFileServer) GetHandlingFunction

func (zf *ZipFileServer) GetHandlingFunction(mime string, file *zip.File, fm time.Time) func(w http.ResponseWriter, r *http.Request)

func (*ZipFileServer) GetHandlingMemFunction

func (zf *ZipFileServer) GetHandlingMemFunction(mime string, file *zip.File, fm time.Time) func(w http.ResponseWriter, r *http.Request)

func (*ZipFileServer) MapFiles

func (zf *ZipFileServer) MapFiles(mux *http.ServeMux) error

func (*ZipFileServer) ParseJSONMIME

func (zf *ZipFileServer) ParseJSONMIME() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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