drpcctx

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: MIT Imports: 3 Imported by: 3

README

package drpcctx

import "storj.io/drpc/drpcctx"

Package drpcctx has helpers to interact with context.Context.

Usage

func Transport
func Transport(ctx context.Context) (drpc.Transport, bool)

Transport returns the drpc.Transport associated with the context and a bool if it existed.

func WithTransport
func WithTransport(ctx context.Context, tr drpc.Transport) context.Context

WithTransport associates the drpc.Transport as a value on the context.

type Tracker
type Tracker struct {
	context.Context
}

Tracker keeps track of launched goroutines with a context.

func NewTracker
func NewTracker(ctx context.Context) *Tracker

NewTracker creates a Tracker bound to the provided context.

func (*Tracker) Cancel
func (t *Tracker) Cancel()

Cancel cancels the tracker's context.

func (*Tracker) Run
func (t *Tracker) Run(cb func(ctx context.Context))

Run starts a goroutine running the callback with the tracker as the context.

func (*Tracker) Wait
func (t *Tracker) Wait()

Wait blocks until all callbacks started with Run have exited.

type TransportKey
type TransportKey struct{}

TransportKey is used to store the drpc.Transport with the context.

Documentation

Overview

Package drpcctx has helpers to interact with context.Context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Transport

func Transport(ctx context.Context) (drpc.Transport, bool)

Transport returns the drpc.Transport associated with the context and a bool if it existed.

func WithTransport

func WithTransport(ctx context.Context, tr drpc.Transport) context.Context

WithTransport associates the drpc.Transport as a value on the context.

Types

type Tracker added in v0.0.2

type Tracker struct {
	context.Context
	// contains filtered or unexported fields
}

Tracker keeps track of launched goroutines with a context.

func NewTracker added in v0.0.2

func NewTracker(ctx context.Context) *Tracker

NewTracker creates a Tracker bound to the provided context.

func (*Tracker) Cancel added in v0.0.2

func (t *Tracker) Cancel()

Cancel cancels the tracker's context.

func (*Tracker) Run added in v0.0.2

func (t *Tracker) Run(cb func(ctx context.Context))

Run starts a goroutine running the callback with the tracker as the context.

func (*Tracker) Wait added in v0.0.2

func (t *Tracker) Wait()

Wait blocks until all callbacks started with Run have exited.

type TransportKey added in v0.0.24

type TransportKey struct{}

TransportKey is used to store the drpc.Transport with the context.

Jump to

Keyboard shortcuts

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