linker

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package linker contains the linking stage logic.

The linking stage goes after the compilation stage. It gets a bunch of promise objects from all documents on the one hand and the bunch of compilation artifacts from all documents on the other, and then tries to bind them together. That is, the linker performs the late binding for promises.

Basically, promises act as placeholders for the related objects that may not be yet compiled. Internally, the promise is just a pointer (nil initially) with metadata on how to find an object(s) it should point to. Linker searches for the object and assigns it to that pointer. See also [asyncapi] package description.

There are several types of promises:

  • a regular promise, points to a single object. May address the object by ref or by a callback. Internal purposes only.
  • [lang.Ref] object. A promise that is used especially for $ref urls in documents. Addresses a single object only by ref.
  • a list promise. For internal purposes only, points to a list of objects. Addresses the objects by a callback only.

Due to different implementations the list promises and the other types are resolved separately.

Linking stage is considered successful if all promises have been resolved. If not, it returns an error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveListPromises

func ResolveListPromises(sources map[string]ObjectSource)

func ResolvePromises

func ResolvePromises(sources map[string]ObjectSource)

func Stats

func Stats(sources map[string]ObjectSource) string

Stats returns a string with the statistics of the linking stage.

func UnresolvedPromises

func UnresolvedPromises(sources map[string]ObjectSource) []string

func UnresolvedPromisesCount

func UnresolvedPromisesCount(sources map[string]ObjectSource) int

Types

type ObjectSource

type ObjectSource interface {
	Artifacts() []common.Artifact // TODO: make this as interface and move promise.go to linker
	Promises() []common.ObjectPromise
	ListPromises() []common.ObjectListPromise
}

Jump to

Keyboard shortcuts

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