namespace

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RootNamespaceID = "root"
)

Variables

View Source
var (
	ErrNoNamespace = errors.New("no namespace")
	RootNamespace  = &Namespace{
		ID:   RootNamespaceID,
		Path: "",
	}
)

Functions

func Canonicalize

func Canonicalize(nsPath string) string

Canonicalize trims any prefix '/' and adds a trailing '/' to the provided string

func ContextWithNamespace

func ContextWithNamespace(ctx context.Context, ns *Namespace) context.Context

func RootContext

func RootContext(ctx context.Context) context.Context

func SplitIDFromString

func SplitIDFromString(input string) (string, string)

Types

type Namespace

type Namespace struct {
	ID   string `json:"id"`
	Path string `json:"path"`
}

func FromContext

func FromContext(ctx context.Context) (*Namespace, error)

This function caches the ns to avoid doing a .Value lookup over and over, because it's called a *lot* in the request critical path. .Value is concurrency-safe so uses some kind of locking/atomicity, but it should never be read before first write, plus we don't believe this will be called from different goroutines, so it should be safe.

func (*Namespace) HasParent

func (n *Namespace) HasParent(possibleParent *Namespace) bool

func (*Namespace) TrimmedPath

func (n *Namespace) TrimmedPath(path string) string

Jump to

Keyboard shortcuts

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