Morecontext - Context.Context helpers to make your life slightly easier

morecontext

context.Context helpers to make your life slightly easier.

-- import "github.com/gopuff/morecontext"

Usage

func ForSignals

func ForSignals(sigs ...os.Signal) context.Context

ForSignals returns a context.Context that will be cancelled if the given signals (or SIGTERM and SIGINT by default, if none are passed) are received by the process.

func WithMessage

func WithMessage(ctx context.Context, format string, args ...interface{}) context.Context

WithMessage is a helper for creating a MessageContext instance, with more context about exactly which context cancellation occurred.

type MessageContext

type MessageContext struct {
	context.Context
	Message string
}

MessageContext is a context.Context wrapper that is intended to include some extra metadata about which context was cancelled. Useful for distinguishing e.g. http request cancellation vs deadline vs process sigterm handling.

func (MessageContext) Err

func (c MessageContext) Err() error

Err returns an error with extra context messaging

type MessageError

type MessageError struct {
	Message  string
	Original error
}

MessageError implements error but separates the message from the original error in case you want it.

func (*MessageError) Error

func (c *MessageError) Error() string

Error implements error and prints out the message plus the metadata about which context was cancelled.

func (*MessageError) Unwrap

func (c *MessageError) Unwrap() error

Unwrap supports errors.Is/errors.As

Owner
Gopuff
Gopuff delivers everyday essentials in minutes.
Gopuff
Similar Resources

Automatically resize your ebs

ebs-autoresize Automatically resize your ebs. Table of Contents ebs-autoresize Table of Contents Installing Getting Started Resize Best practices Cont

Oct 16, 2022

efsu is for accessing AWS EFS from your machine without a VPN

efsu: VPN-less access to AWS EFS efsu is for accessing AWS EFS from your machine without a VPN. It achieves this by deploying a Lambda function and sh

Mar 11, 2022

A "passwordless" login experience for your AWS RDS

A

RDS Auth Proxy A two-layer proxy for connecting into RDS postgres databases based on IAM authentication. This tool allows you to keep your databases f

Dec 28, 2022

Plot your repository stars over time.

Plot your repository stars over time.

Dec 30, 2022

Automatically roll your AWS IAM access key (aws_access_key_id) and secret key (aws_secret_access_key).

roll-it Keep your AWS Credentials fresh 🍊 on Windows, Mac, Linux (arm or x86)! What it Does Programmatically rotate your AWS IAM access keys and secr

Jan 6, 2023

Use Google REST api to extract your personal Photo Library

Photo Go A better approach to extracting your photos from Google to your personal cloud. I'm moving my photos out of Google to a Synology NAS. create

Dec 7, 2021

Easily manage your github credentials

Easily manage your github credentials

HUB ADMIN Hub Admin is a command-line tool managing your github credentials Installation go get github.com/crewdevio/HubAdmin How to use Open he

Oct 20, 2021

Quick add or delete ASN/AS-SET to your AS-SET through RIPE RESTful API

RIPE AS-SET updater Quick add or delete ASN/AS-SET to your AS-SET through RIPE RESTful API. Requirenments You need to add "auth:" attribute in mntner

Apr 19, 2022

A command-line tool to pretty print your system's PATH environment variable.

A command-line tool to pretty print your system's PATH environment variable.

Description A command-line tool to pretty print your system's PATH environment variable. The output paths are colorized if they have special associati

Nov 9, 2022
A simple package in Golang containing helpers for functional programming

go-functools Golang package containing functools using Go generics functools is

Nov 3, 2022
Using Golang to complete ChatGPT streaming, making it easier to join your own project
Using Golang to complete ChatGPT streaming, making it easier to join your own project

chatGPT_streaming go语言使用openai的ChatGPT接口实践,使用流式传输,类似ChatGPT网页效果,并且可以让ChatGPT的服务单独部署(单独部署到非大中华区的服务器),并用grpc streaming 做中间层,保证不受墙的影响。使用websocket最终通信,后端考

May 11, 2023
Add request id to a request's context

RequestID ?? This is a very simple piece of middleware for adding request/correlation IDs to the context of a http request. By default, this module wi

Dec 4, 2021
I try to make a Restfull-API with golang and interaction with json.file

{ "users": [ { "name": "Elliot", "type": "Reader", "age": 23, "social": { "facebook": "https://facebook.com",

Jan 5, 2022
advancedsearch is a package to help peoples make search while typing "char" by "char" in Golang.

advancedsearch is a package to help peoples make search while typing "char" by "char" in Golang. Actually he has two main functions, CompareSingleWord and CompareMultipleWords.

Feb 2, 2022
💅🏽💄 A local development tool to replace docker-compose, based on Make
💅🏽💄 A local development tool to replace docker-compose, based on Make

???? Makeup ?? A local development tool to replace Docker Compose, based on Make. Makeup uses simple Makefiles to create a faster developer workflow c

Dec 2, 2022
A simple api built in Go that facilitates directly sending email from your client side html to your inbox

go-email-service A simple api built in Go that facilitates directly sending emai

Dec 28, 2021
Sync your bank transactions with google sheets using Open Banking APIs

Sync your bank transactions with google sheets using Open Banking APIs

Jul 22, 2022
Lambda stack to turn off and destroy all resources from your personal AWS Account to avoid billing surprises
Lambda stack to turn off and destroy all resources from your personal AWS Account to avoid billing surprises

AWS, Turn off my Account, please Lambda stack to turn off and destroy all resources from your personal AWS Account to avoid billing surprises Resource

Oct 25, 2022
Sync your bank transactions with google sheets using Open Banking APIs

this is a markdown version of the copy on the site landing page: https://youneedaspreadsheet.com You need a spreadsheet ?? Get on top of your finances

Jul 22, 2022