🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

github.com/ancientlore/ctxmap

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/ancientlore/ctxmap

v1.0.2
Source
Go
Version published
Created
Source

ctxmap

Go Reference

Package ctxmap implements a registry for global context.Context for use in web applications.

Based on work from github.com/gorilla/context, this package simplifies the storage by mapping a pointer to an http.Request to a context.Context. This allows applications to use Google's standard context mechanism to pass state around their web applications, while sticking to the standard http.HandlerFunc implementation for their middleware implementations.

As a result of the simplification, the runtime overhead of the package is reduced by 35 to 50 percent in my tests. However, it would be common to store a map of values or a pointer to a structure in the Context object, and my testing does not account for time taken beyond calling Context.Value().

BenchmarkReadersWritersIterationsMap Opscontextctxmap
BenchmarkMutexSameReadWrite1113264208.91 ns102.63 ns
BenchmarkMutexSameReadWrite22232128211.27 ns103.97 ns
BenchmarkMutexSameReadWrite44432256216.21 ns101.54 ns
BenchmarkMutex12832320252.26 ns92.62 ns
BenchmarkMutex2164641280166.85 ns108.31 ns
BenchmarkMutex312128384221.67 ns78.47 ns
BenchmarkMutex41283225640960179.70 ns107.31 ns
BenchmarkMutex51024204864196608233.41 ns90.10 ns
BenchmarkMutex6204810245121572864183.25 ns92.33 ns

FAQs

Package last updated on 04 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts