engineutil

package
v1.0.0-beta.12 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: Apache-2.0 Imports: 105 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DaggerSessionIDEnv       = "_DAGGER_SESSION_ID"
	DaggerClientIDEnv        = "_DAGGER_NESTED_CLIENT_ID"
	DaggerCallDigestEnv      = "_DAGGER_CALL_DIGEST"
	DaggerEngineVersionEnv   = "_DAGGER_ENGINE_VERSION"
	DaggerRedirectStdinEnv   = "_DAGGER_REDIRECT_STDIN"
	DaggerRedirectStdoutEnv  = "_DAGGER_REDIRECT_STDOUT"
	DaggerRedirectStderrEnv  = "_DAGGER_REDIRECT_STDERR"
	DaggerHostnameAliasesEnv = "_DAGGER_HOSTNAME_ALIASES"
	DaggerNoInitEnv          = "_DAGGER_NOINIT"

	DaggerSessionPortEnv  = "DAGGER_SESSION_PORT"
	DaggerSessionTokenEnv = "DAGGER_SESSION_TOKEN"
	DaggerEngineNumCPUEnv = "DAGGER_ENGINE_NUM_CPU"

	DaggerQemuEmulatorMountPoint = "/dev/.dagger_qemu_emulator"
)
View Source
const (
	// Exec errors will only include the last this number of bytes of output.
	MaxExecErrorOutputBytes = 100 * 1024

	// TruncationMessage is the message that will be prepended to truncated output.
	TruncationMessage = "[omitting %d bytes]..."

	// MaxFileContentsChunkSize sets the maximum chunk size for ReadFile calls
	// Equals around 95% of the max message size (4MB) in
	// order to keep space for any Protocol Buffers overhead:
	MaxFileContentsChunkSize = 3984588

	// MaxFileContentsSize sets the limit of the maximum file size
	// that can be retrieved using File.Contents, currently set to 128MB:
	MaxFileContentsSize = 128 << 20

	// MetaMountDestPath is the special path that the shim writes metadata to.
	MetaMountDestPath           = "/.dagger_meta_mount"
	MetaMountExitCodePath       = "exitCode"
	MetaMountStdoutPath         = "stdout"
	MetaMountStderrPath         = "stderr"
	MetaMountCombinedOutputPath = "combinedOutput"
)
View Source
const InstrumentationLibrary = "dagger.io/engine.buildkit"

Variables

View Source
var ErrGitCheckoutStateChanged = errors.New("git checkout state changed")

ErrGitCheckoutStateChanged reports that a checkout moved while the engine was selecting or receiving its pack. The caller should read its state again and retry under the new cache key.

View Source
var ErrGitPackUnsupported = errors.New("client cannot pack git checkouts")

ErrGitPackUnsupported reports that the client cannot pack a checkout with its own git: either the client predates the PackCheckout RPC or it has no git binary. Callers may degrade to whatever git state the synced tree itself carries.

View Source
var ErrGitUncommittedUnsupported = errors.New("client cannot pack git worktrees")

ErrGitUncommittedUnsupported reports that the client cannot provide a packed working-tree delta. Callers may fall back to syncing the checkout directory.

View Source
var SkipInputs = fmt.Errorf("skip inputs") //nolint:staticcheck // Err prefix isn't convention for Walk control errors

Functions

func NewSecretScrubReader

func NewSecretScrubReader(
	r io.Reader,
	env []string,
	secretEnvs []string,
	secretFiles []string,
) (io.Reader, error)

func ReadSnapshotPath

func ReadSnapshotPath(ctx context.Context, c *Client, mntable bkcache.MountableRef, filePath string, limit int) ([]byte, error)

func RunInNetNS

func RunInNetNS[T any](
	ctx context.Context,
	c *Client,
	ns Namespaced,
	fn func() (T, error),
) (T, error)

func ScrubStrings

func ScrubStrings(env, secretEnvs, secretFiles, in []string) ([]string, error)

ScrubStrings redacts the engine's registered session secrets from each input string, returning a new slice (the input is left unchanged). It builds the secret trie ONCE from the same (env, secretEnvs, secretFiles) the stdout/stderr scrubbers use, so a value scrubbed from process output is scrubbed here too. All inputs may be nil/empty: with no registered secrets the strings pass through unchanged (an empty trie matches nothing). Used to redact a user exec's argv before it is emitted to the wcprof profile (native + OTel).

func ShutdownGlobalNamespaceWorkerPool

func ShutdownGlobalNamespaceWorkerPool()

ShutdownGlobalNamespaceWorkerPool gracefully shuts down the global namespace worker pool This should be called during application shutdown

func StateIdx

func StateIdx(ctx context.Context, st llb.State, idx solverpb.OutputIndex, c *llb.Constraints) llb.State

func Tracer

func Tracer(ctx context.Context) trace.Tracer

Types

type BlobOp

type BlobOp struct {
	*OpDAG
	*pb.SourceOp
}

func (*BlobOp) Digest

func (op *BlobOp) Digest() (digest.Digest, error)

type Client

type Client struct {
	*Opts
	// contains filtered or unexported fields
}

Client is dagger's internal engine utility client

func NewClient

func NewClient(ctx context.Context, opts *Opts) (*Client, error)

func (*Client) AbsPath

func (c *Client) AbsPath(ctx context.Context, path string) (string, error)

Return the absolute path of the given path as calculated by the caller's host using OS-specific rules.

func (*Client) Exec

func (c *Client) Exec(ctx context.Context, id string, process executor.ProcessInfo) (err error)

func (*Client) ExportContainerImage

func (c *Client) ExportContainerImage(
	ctx context.Context,
	destPath string,
	inputByPlatform map[string]ContainerExport,
	forceCompression string,
	tarExport bool,
	_ string,
	useOCIMediaTypes bool,
) (*imageexport.ExportResponse, error)

func (*Client) GetCredential

func (c *Client) GetCredential(ctx context.Context, protocol, host, path string) (*git.CredentialInfo, error)

func (*Client) GetGitConfig

func (c *Client) GetGitConfig(ctx context.Context) ([]*git.GitConfigEntry, error)

func (*Client) GetSessionCaller

func (c *Client) GetSessionCaller(ctx context.Context) (_ SessionCaller, rerr error)

func (*Client) GitCheckoutState

func (c *Client) GitCheckoutState(ctx context.Context, checkoutPath string) (string, error)

GitCheckoutState asks the client for a digest of a local checkout's current git state (HEAD, symbolic HEAD, branch and tag refs), resolved by the client's own git so every checkout layout works. The digest changes exactly when the checkout's refs move, making it the cache key for PackGitCheckout.

A checkout that is not a git repository reports gitutil.ErrGitNoRepo.

func (*Client) GlobCallerHostPath

func (c *Client) GlobCallerHostPath(ctx context.Context, dir string, pattern string) ([]string, error)

func (*Client) IOReaderExport

func (c *Client) IOReaderExport(ctx context.Context, r io.Reader, destPath string, destMode os.FileMode) (rerr error)

IOReaderExport exports the contents of an io.Reader to the caller's local fs as a file TODO: de-dupe this with the above method to extent possible

func (*Client) ListenHostToContainer

func (c *Client) ListenHostToContainer(
	ctx context.Context,
	hostListenAddr, proto, upstream string,
) (*h2c.ListenResponse, func() error, error)

func (*Client) LocalDirExport

func (c *Client) LocalDirExport(
	ctx context.Context,
	srcPath string,
	destPath string,
	merge bool,
	removePaths []string,
) (rerr error)

func (*Client) LocalFileExport

func (c *Client) LocalFileExport(
	ctx context.Context,
	srcPath string,
	filePath string,
	destPath string,
	allowParentDirPath bool,
) (rerr error)

func (*Client) NewNetworkNamespace

func (c *Client) NewNetworkNamespace(ctx context.Context, hostname string) (Namespaced, error)

func (*Client) OpenPipe

func (c *Client) OpenPipe(
	ctx context.Context,
) (io.ReadWriteCloser, error)

func (*Client) OpenTerminal

func (c *Client) OpenTerminal(
	ctx context.Context,
) (*TerminalClient, error)

func (*Client) PackGitCheckout

func (c *Client) PackGitCheckout(ctx context.Context, checkoutPath, expectedStateDigest string) (_ *GitCheckoutPack, rerr error)

PackGitCheckout asks the client to pack a local checkout's repository with its own git. See GitCheckoutPack. A checkout that is not a git repository reports gitutil.ErrGitNoRepo.

func (*Client) PackGitUncommitted

func (c *Client) PackGitUncommitted(ctx context.Context, checkoutPath, expectedHeadSHA string) (_ *GitUncommittedPack, rerr error)

PackGitUncommitted asks the client to stream the working-tree delta relative to expectedHeadSHA. Older clients and checkout states without a canonical HEAD report ErrGitUncommittedUnsupported so callers can retain the directory-sync fallback.

func (*Client) PrepareContainerImage

func (c *Client) PrepareContainerImage(
	ctx context.Context,
	inputByPlatform map[string]ContainerExport,
	useOCIMediaTypes bool,
	forceCompression string,
) (*PreparedContainerImage, error)

func (*Client) PromptAllowLLM

func (c *Client) PromptAllowLLM(ctx context.Context, moduleRepoURL string) error

func (*Client) PromptHumanHelp

func (c *Client) PromptHumanHelp(ctx context.Context, title, question string) (string, error)

func (*Client) PublishContainerImage

func (c *Client) PublishContainerImage(
	ctx context.Context,
	inputByPlatform map[string]ContainerExport,
	refName string,
	useOCIMediaTypes bool,
	forceCompression string,
	network serverresolver.NetworkConfig,
	registryTransport serverresolver.RegistryTransport,
) (*imageexport.ExportResponse, error)

func (*Client) ReadCallerHostFile

func (c *Client) ReadCallerHostFile(ctx context.Context, path string) ([]byte, error)

func (*Client) ReadImage

func (c *Client) ReadImage(
	ctx context.Context,
	name string,
) (*ImageReader, error)

func (*Client) Run

func (c *Client) Run(
	ctx context.Context,
	id string,
	rootMount executor.Mount,
	mounts []executor.Mount,
	procInfo executor.ProcessInfo,
	started chan<- struct{},
	causeCtx trace.SpanContext,
	execMD *ExecutionMetadata,
	sessionID string,
	callerClientID string,
	nestedClientMetadata *engine.ClientMetadata,
	nestedClientModule dagql.AnyObjectResult,
	nestedClientFunctionCall dagql.Typed,
) (rerr error)

func (*Client) SearchCallerHostPath

func (c *Client) SearchCallerHostPath(ctx context.Context, dir string, opts *engine.LocalSearchOpts) ([]engine.LocalSearchResult, error)

func (*Client) StatCallerHostPath

func (c *Client) StatCallerHostPath(ctx context.Context, path string, returnAbsPath bool) (*fsutiltypes.Stat, error)

func (*Client) WriteContainerImageTarball

func (c *Client) WriteContainerImageTarball(
	ctx context.Context,
	w io.Writer,
	inputByPlatform map[string]ContainerExport,
	useOCIMediaTypes bool,
	forceCompression string,
) error

func (*Client) WriteImage

func (c *Client) WriteImage(
	ctx context.Context,
	name string,
) (*ImageWriter, error)

type ContainerExport

type ContainerExport struct {
	Ref         bkcache.ImmutableRef
	Config      dockerspec.DockerOCIImageConfig
	Annotations []containerutil.ContainerAnnotation
}

type ContainerImageBlob

type ContainerImageBlob struct {
	// contains filtered or unexported fields
}

func (ContainerImageBlob) Descriptor

func (blob ContainerImageBlob) Descriptor() specs.Descriptor

func (ContainerImageBlob) WriteTo

func (blob ContainerImageBlob) WriteTo(ctx context.Context, dst io.Writer) error

type DiffOp

type DiffOp struct {
	*OpDAG
	*pb.DiffOp
}

type ExecOp

type ExecOp struct {
	*OpDAG
	*pb.ExecOp
}

func (*ExecOp) Input

func (exec *ExecOp) Input(i pb.InputIndex) *OpDAG

func (*ExecOp) OutputMount

func (exec *ExecOp) OutputMount() *pb.Mount

func (*ExecOp) OutputMountBase

func (exec *ExecOp) OutputMountBase() *OpDAG

type ExecutionMetadata

type ExecutionMetadata struct {
	// Internal execution initiated by dagger and not the user.
	// Used when executing the module runtime itself.
	Internal bool

	// UseRecipeIDsByDefault configures nested clients started by this exec to
	// resolve id() as recipe-form IDs unless explicitly requested otherwise.
	UseRecipeIDsByDefault bool

	CallDigest digest.Digest

	// hostname -> list of aliases
	HostAliases map[string][]string
	// search domains to install prior to the session's domain
	ExtraSearchDomains []string

	RedirectStdinPath  string
	RedirectStdoutPath string
	RedirectStderrPath string

	SecretEnvNames  []string
	SecretFilePaths []string

	SystemEnvNames []string

	EnabledGPUs []string

	// If true, skip injecting dagger-init into the container.
	NoInit bool

	// ProfArgs is the fully-resolved user command (entrypoint + args), captured
	// in core at exec-run time BEFORE any engine shim (the QEMU emulator, the
	// executor's /.init) wraps it, so wall-clock profiling can headline the user's
	// real program (e.g. "go build") instead of a shim. It is read at the executor
	// emit site (executor_spec.go) by both the native recorder and the OTel source.
	//
	// json:"-" is load-bearing: ExecutionMetadata is JSON-serialized into exec
	// cache keys (dagql.SerializedString/DigestedSerializedString), and ProfArgs
	// must never perturb a cache key. It is excluded structurally here; it is also
	// set only at run time (after every execMD digest is computed), and the
	// core->executor hand-off is an in-process pointer (never re-serialized), so
	// excluding it from JSON cannot drop it before the emit.
	ProfArgs []string `json:"-"`

	// UserFacingSpanCtx is the last user-facing (non-profiling) span of the API
	// call this exec runs under, captured in core at exec-setup time (see
	// dagql.UserFacingSpanContext). The executor injects IT as the container's
	// traceparent — not its own current span: the exec runs on a detached
	// execution context (shared/deduped, possibly lazily resumed) whose current
	// span is a profiling span (the call_exec twin / a resume span) and which
	// does not carry the caller's context mark, so only core still knows the
	// user-facing span. Everything the container emits (nested SDK client
	// spans, user process logs, returned Error origin extensions) parents to
	// the injected id, and telemetry parented to an unrendered passthrough span
	// vanishes from the row that should show it.
	//
	// json:"-" is load-bearing for the same reason as ProfArgs above: this
	// run-time-only value must never perturb an exec cache key, and the
	// core->executor hand-off is an in-process pointer, so excluding it from
	// JSON cannot drop it before use.
	UserFacingSpanCtx trace.SpanContext `json:"-"`

	// HostAliasFQDNs maps a HostAliases key (a bound service's advertised
	// hostname) to the fully qualified name the running service actually
	// registered in DNS under. A service with a custom hostname is namespaced
	// into the domain of whichever module started it (core.Service.startContainer),
	// and that FQDN is the only name the dnsname CNI plugin registers. The
	// consuming exec only searches its own module domain plus the session
	// domain, so re-deriving the name from the bare hostname fails outright
	// whenever the service was first started by a different module. Recording
	// the FQDN keeps an explicit WithServiceBinding working across that
	// boundary without installing the producer's domain as a search domain,
	// which would expose every other service scoped to it.
	//
	// Only entries for names in the engine's DNS domain are set; tunnel
	// services report a host-side dial address instead and must keep resolving
	// through the search-domain sweep in setupNetwork.
	//
	// json:"-" is load-bearing for the same reason as ProfArgs above: this
	// run-time-only value must never perturb an exec cache key, and the
	// core->executor hand-off is an in-process pointer, so excluding it from
	// JSON cannot drop it before use.
	HostAliasFQDNs map[string]string `json:"-"`
}

type FileOp

type FileOp struct {
	*OpDAG
	*pb.FileOp
}

type GitCheckoutPack

type GitCheckoutPack struct {
	HeadSHA      string
	HeadRef      string
	ObjectFormat string
	StateDigest  string
	BundlePath   string
}

GitCheckoutPack is a client checkout's repository, packed by the client's own git: a bundle of HEAD plus all branches and tags, with the metadata needed to reconstruct a standalone repository from it. A repository with no commits yet (unborn HEAD) has an empty HeadSHA and no BundlePath. The caller must call Close to release the owned bundle file.

func (*GitCheckoutPack) Close

func (pack *GitCheckoutPack) Close() error

Close releases the checkout bundle owned by pack.

type GitOp

type GitOp struct {
	*OpDAG
	*pb.SourceOp
}

type GitUncommittedPack

type GitUncommittedPack struct {
	HeadSHA            string
	NestedRepositories []string
	PatchPath          string
}

GitUncommittedPack is a checkout's git-visible working-tree delta relative to HeadSHA. PatchPath names an owned binary git patch. NestedRepositories are omitted from the patch but retain their boundaries when it is materialized engine-side. The caller must call Close to release the patch file.

func (*GitUncommittedPack) Close

func (pack *GitUncommittedPack) Close() error

Close releases the uncommitted patch owned by pack.

type GlobalNamespaceWorkerPool

type GlobalNamespaceWorkerPool struct {
	// contains filtered or unexported fields
}

GlobalNamespaceWorkerPool manages a global pool of workers that can enter different namespace contexts based on PID and namespace type

func GetGlobalNamespaceWorkerPool

func GetGlobalNamespaceWorkerPool() *GlobalNamespaceWorkerPool

GetGlobalNamespaceWorkerPool returns the singleton global namespace worker pool

func (*GlobalNamespaceWorkerPool) RunInNamespaces

func (gwp *GlobalNamespaceWorkerPool) RunInNamespaces(ctx context.Context, containerID string, namespaces []specs.LinuxNamespace, fn func() error) error

RunInNamespaces executes a function in the context of specific namespaces for a given PID

func (*GlobalNamespaceWorkerPool) Start

func (gwp *GlobalNamespaceWorkerPool) Start()

Start initializes and starts the global worker pool

func (*GlobalNamespaceWorkerPool) Stop

func (gwp *GlobalNamespaceWorkerPool) Stop()

Stop gracefully shuts down the global worker pool

func (*GlobalNamespaceWorkerPool) SubmitJob

func (gwp *GlobalNamespaceWorkerPool) SubmitJob(ctx context.Context, job *NamespaceJob) error

SubmitJob submits a job to be executed in the specified namespace context

type HTTPOp

type HTTPOp struct {
	*OpDAG
	*pb.SourceOp
}

type ImageOp

type ImageOp struct {
	*OpDAG
	*pb.SourceOp
}

type ImageReader

type ImageReader struct {
	Tarball io.ReadCloser

	ContentStore content.Store
	ImagesStore  images.Store
	LeaseManager leases.Manager
}

type ImageWriter

type ImageWriter struct {
	Tarball io.WriteCloser

	ContentStore content.Store
	ImagesStore  images.Store
	LeaseManager leases.Manager
}

type LocalOp

type LocalOp struct {
	*OpDAG
	*pb.SourceOp
}

type MergeOp

type MergeOp struct {
	*OpDAG
	*pb.MergeOp
}

type NamespaceJob

type NamespaceJob struct {
	Container  string                 // Container whose namespaces to enter
	Namespaces []specs.LinuxNamespace // Namespaces to enter (e.g., network, mount, etc.)
	Fn         func() error           // Function to execute
	ResultCh   chan error             // Channel to send result back
}

NamespaceJob represents a job to be executed in a specific namespace context

type Namespaced

type Namespaced interface {
	NamespaceID() string
	Release(context.Context) error
}

Namespaced is something that has Linux namespaces set up. Currently this is either a full-blown container or just a raw network namespace that's setns'd into to support service tunneling and similar.

func NewDirectNS

func NewDirectNS(id string) Namespaced

NewDirectNS creates a namespace, that's externally managed.

type OCIOp

type OCIOp struct {
	*OpDAG
	*pb.SourceOp
}

type OpDAG

type OpDAG struct {
	*pb.Op                  // the root of the DAG
	OpDigest *digest.Digest // the digest of this root, common across all outputIndexes for this root
	Metadata *pb.OpMetadata // metadata for the root
	Inputs   []*OpDAG       // the inputs to the root
	// contains filtered or unexported fields
}

func DefToDAG

func DefToDAG(def *pb.Definition) (*OpDAG, error)

func (*OpDAG) AsBlob

func (dag *OpDAG) AsBlob() (*BlobOp, bool)

func (*OpDAG) AsDiff

func (dag *OpDAG) AsDiff() (*DiffOp, bool)

func (*OpDAG) AsExec

func (dag *OpDAG) AsExec() (*ExecOp, bool)

func (*OpDAG) AsFile

func (dag *OpDAG) AsFile() (*FileOp, bool)

func (*OpDAG) AsGit

func (dag *OpDAG) AsGit() (*GitOp, bool)

func (*OpDAG) AsHTTP

func (dag *OpDAG) AsHTTP() (*HTTPOp, bool)

func (*OpDAG) AsImage

func (dag *OpDAG) AsImage() (*ImageOp, bool)

func (*OpDAG) AsLocal

func (dag *OpDAG) AsLocal() (*LocalOp, bool)

func (*OpDAG) AsMerge

func (dag *OpDAG) AsMerge() (*MergeOp, bool)

func (*OpDAG) AsOCI

func (dag *OpDAG) AsOCI() (*OCIOp, bool)

func (*OpDAG) EffectID

func (dag *OpDAG) EffectID() string

func (*OpDAG) Marshal

func (dag *OpDAG) Marshal() (*pb.Definition, error)

Marshal will convert the dag back to a flat pb.Definition, updating all digests based on any modifications made to the dag.

func (*OpDAG) OutputIndex

func (dag *OpDAG) OutputIndex() pb.OutputIndex

OutputIndex returns the specific output of this op represented by this OpDAG instance.

func (*OpDAG) String

func (dag *OpDAG) String() string

func (*OpDAG) Walk

func (dag *OpDAG) Walk(f func(*OpDAG) error) error

type Opts

type Opts struct {
	ID               string
	Labels           map[string]string
	Platforms        []ocispecs.Platform
	NetworkProviders map[pb.NetMode]network.Provider
	Snapshotter      bkcache.Snapshotter
	ContentStore     *containerdsnapshot.Store
	Applier          diff.Applier
	Differ           diff.Comparer
	IdentityMapping  *idtools.IdentityMapping

	ExecutorRoot    string
	TelemetryPubSub http.Handler
	SessionHandler  sessionHandler

	Runc                *runc.Runc
	DefaultCgroupParent string
	ProcessMode         oci.ProcessMode
	DNSConfig           *oci.DNSConfig
	ApparmorProfile     string
	SELinux             bool
	Entitlements        entitlements.Set

	HostMntNS  *os.File
	CleanMntNS *os.File

	Dialer               *net.Dialer
	GetClientCaller      func(context.Context, string) (SessionCaller, error)
	GetHostServiceCaller func(context.Context, string) (SessionCaller, error)
	GetMainClientCaller  func(context.Context) (SessionCaller, error)
	GetRegistryResolver  func(context.Context) (*serverresolver.Resolver, error)

	Interactive        bool
	InteractiveCommand []string
	// contains filtered or unexported fields
}

Opts combines server-scoped runtime dependencies with per-client session plumbing. Server-scoped fields are initialized once with NewOpts and shallow-copied for each client.

func NewOpts

func NewOpts(opts Opts) (*Opts, error)

func (*Opts) Close

func (opts *Opts) Close() error

type PreparedContainerImage

type PreparedContainerImage struct {
	// contains filtered or unexported fields
}

func (*PreparedContainerImage) Blob

func (*PreparedContainerImage) Manifest

func (image *PreparedContainerImage) Manifest() ContainerImageBlob

type SessionCaller

type SessionCaller interface {
	Conn() *grpc.ClientConn
	Supports(method string) bool
}

type TerminalClient

type TerminalClient struct {
	Stdin    io.ReadCloser
	Stdout   io.WriteCloser
	Stderr   io.WriteCloser
	ResizeCh chan bkgw.WinSize
	ErrCh    chan error
	Close    func(exitCode int) error
}

type Trie

type Trie struct {
	// contains filtered or unexported fields
}

Trie is a simple implementation of a compressed trie (or radix tree). In essence, it's a key-value store that allows easily selecting all entries that have a given prefix.

Why not an off-the-shelf implementation? Well, most of those don't allow navigating character-by-character through the tree, like we do with Step.

func (*Trie) Insert

func (t *Trie) Insert(key []byte, value []byte)

func (*Trie) Iter

func (t *Trie) Iter() *TrieIter

func (*Trie) Step

func (t *Trie) Step(ch byte) *TrieIter

func (Trie) String

func (t Trie) String() string

String prints a debuggable representation of the trie.

type TrieIter

type TrieIter struct {
	*Trie
	// contains filtered or unexported fields
}

TrieIter is an iterator that allows navigating through a Trie.

This is used so that we can navigate through the compressed Trie structure easily - not every node "exists", but the TrieIter handles this case. For example, a node might have a direct of `foo`, so the node `fo` is virtual.

func (*TrieIter) Step

func (t *TrieIter) Step(ch byte) *TrieIter

Step selects a node that was previously inserted.

func (*TrieIter) Value

func (t *TrieIter) Value() []byte

Value gets the value previously inserted at this node.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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