cookie

package
v0.0.0-...-580f94b Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cookie implements a specialized version of a context - It is cancellable - It has a channel associated with it to reply to state callbacks - It can be marshalled by having a cgo Handle attached to it

Index

Constants

View Source
const CONTEXTK contextt = 0

CONTEXTK is the key of the cookie

Variables

This section is empty.

Functions

This section is empty.

Types

type Cookie struct {
	H cgo.Handle
	// contains filtered or unexported fields
}

Cookie is the cookie which is just a context with some other data associated with it We could potentially only uses contexts with values, but this is nicer for type checking

func NewWithContext

func NewWithContext(ctx context.Context) *Cookie

NewWithContext creates a new cookie with a context It stores the cancel and channel inside of the struct

func (*Cookie) Cancel

func (c *Cookie) Cancel() error

Cancel cancels the cookie by calling the context cancel function It returns an error if no such function exists

func (*Cookie) Context

func (c *Cookie) Context() context.Context

Context gets the underlying context of the cookie

func (*Cookie) MarshalJSON

func (c *Cookie) MarshalJSON() ([]byte, error)

MarshalJSON marshals the cookie to JSON

func (*Cookie) Receive

func (c *Cookie) Receive(errchan chan error) (string, error)

Receive receives a value from the cookie up until the context is done or errchan gets an error This error chan is used for goroutines to signal errors that we have to exit early

func (*Cookie) Send

func (c *Cookie) Send(data string) error

Send sends data to the cookie channel if the context is not canceled

Jump to

Keyboard shortcuts

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