runtime.link

module
v0.0.0-...-33982d8 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: 0BSD

README

The runtime.link project provides a dictionary for representing software interfaces via Go source. It also provides builtin Go linkers that enable you to link to these interfaces at runtime. They can be connected via network protocols (ie. HTTP), through command line interfaces, or through a supported platform-native ABI.

This repo also serves as a home for Go source representations written using the runtime.link dictionary. Our primary aim is to promote the practise of representing software interfaces and specifications as source code, rather than a PDF document.

The project is still in development and although we don't plan to make any major changes to established components before the first stable release, there may be continue to be minor breaking changes here and there as we work to refine the exported interfaces.

Example:

// Package example provides the specification for the runtime.link example API.
package example

import (
	"log"
	"os"

	"runtime.link/api"
)

// API specification structure, typically named API for general structures, may
// be more suitably named Functions, Library or Command when the API is
// restricted to a specific runtime.link layer. Any Go comments in the source
// are intended to document design notes and ideas. This leaves Go struct tags
// for recording developer-facing documentation.
type API struct {
	api.Specification `api:"Example" cmd:"example" lib:"libexample"
		is an example of a runtime.link API structure.` // this section of the tag contains documentation.

	// HelloWorld includes runtime.link tags that specify how the function is called
	// across different link-layers. Typically, a context.Context argument and error
	// return value should be included here, they are omitted here for brevity.
	HelloWorld func() string `args:"hello_world" link:"example_helloworld func()$char" rest:"GET /hello_world"
		returns the string "Hello World"` // documentation for the function.
}

// New returns an implementation of the API. This doesn't have to be defined in the
// same package and may not even be implemented in Go. This will often be the case when
// representing an external API controlled by a third-party.
func New() API {
	return API{
		HelloWorld: func() string {
			return "Hello World"
		},
	}
}

More Practical Examples

Runtime Linkers.

Each linker lives under the api package and enables an API to be linked against a host implementation via a standard communication protocol. A linker can also serve a host implementation written in Go.

Currently available runtime.linkers include:

* args - parse command line arguments or execute command line programs.
* link - generate c-shared export directives or dynamicaly link to shared libraries (via ABI).
* rest - link to, or host a REST API server over the network.
* stub - create a stub implementation of an API, that returns empty values or errors.
* xray - debug linkers with API call introspection.

Data Dictionary

In addition to the link layers the runtime.link project defines additional packages to help represent well-defined, variable data types, strings and structures. These are:

* api - provides reflection and functions for working with runtime.link API structures.
* qty - quantity types, representing specific units of measure.
* ref - create reciever functions for foreign keys, pointer-like values for API values.
* txt - text tags, syntax-specified strings, human readable tag for textual field names.
* xyz - sequence tags, switch types (enums/unions/variants), tuples and optional values.

Resource Dictionary

Most software requires access to external resources, so runtime.link provides a few packages to help clearly represent these resources. These are:

* eon - represent asyncronous scheduling, sleep periods and timers.
* kvs - represent key-value stores.
* pub - represent asyncronous fan out message queues with Pub/Sub semantics.
* sql - represent SQL database maps and construct type-safe queries.

Runtime Optimisation

The runtime.link project provides packages useful for optimising Go functions with runtime specified behaviour. These packages are still in an exploratory state:

* bin - binary bit-level encoding representations (including CPU binary formats).
* jit - compile safe yet dynamic functions at runtime.

Standard Interfaces and Open Source Software

The runtime.link project includes a selection of builtin representations for well-known software standards and interfaces. These are intended to act as a reference on how the package can be utilised and also as readily available interfaces that can be imported into your Go projects. We aim to keep a consistent level of quality for these packages. Currently we are aiming to include a useful representation of:

  • C
  • POSIX
  • OpenGL
  • GNU
  • SODIUM

Common command line programs and shared libraries that are readily available on many systems can be discovered under the 'com', 'std' and 'oss' subdirectories under each link layer.

Proprietary Software Interfaces

If you would like to include a runtime.link API structure for proprietary software (so that it can be made available to all runtime.link users), we can help create this representation for you, please contact us for a quote. Our only requirement is that any resulting runtime.link API structure packages must be released under the same license as runtime.link (BSD0).

Our Design Values

  1. Full readable words for exported identifiers rather than abbreviations ie. PutString over puts.
  2. Acronyms as package names and/or as a suffix, rather than mixed use ie. TheExampleAPI over TheAPIExample.
  3. Explicitly tagged types that define data relationships rather than implicit use of primitives. Customer CustomerID over Customer string.
  4. Don't stutter exported identifiers. customer.Account over customer.Customer.

Contribution Guidance

This project is open for contributions that help update or define clear, compatible runtime.link structures for software standards and interfaces. We will consider pull requests and/or ideas for additional interfaces and/or standards that have well-known and widely available implementations under an Open Source Initiative approved license.

Apart from what's on the Roadmap, we cannot accept any pull requests for new top level packages at this time, although you are welcome to start a GitHub Discussion for any ideas you may have, our current goal for runtime.link is to stick to a well-defined and cohesive design space.

runtime.link aims to be dependency free, we will not accept any pull requests that add any additional Go dependencies to the project.

NOTE: we adopt a different convention for Go struct tags, which are permitted to be multi-line and include inline-documentation on subsequent lines of the tag. This can raise a warning with Go linters, so we recommend using the following configurations:

govet go vet -structtag=false ./...

VS Code + gopls

"go.vetFlags": [
    "-structtag=false"
],
"gopls": {
    "analyses": {
        "structtag": false
    },
},

golangci-lint.yml

linters-settings:
  govet:
    disable:
      - structtag # support runtime.link convention.

Roadmap

  • Support for additional linkers, such as mock, grpc, soap, jrpc, xrpc, and sock.

Directories

Path Synopsis
api
Package api defines the standard runtime reflection representation for a runtime.link API structure.
Package api defines the standard runtime reflection representation for a runtime.link API structure.
args
Package args provides a command-line interface layer for runtime.link.
Package args provides a command-line interface layer for runtime.link.
call
Package call provides shared library linker for runtime.link (WORK-IN-PROGRESS).
Package call provides shared library linker for runtime.link (WORK-IN-PROGRESS).
call/internal/abi
Package abi provides an interface to the platform-standard ABI calling conventions and type system (typically C).
Package abi provides an interface to the platform-standard ABI calling conventions and type system (typically C).
call/internal/cgo
Code generated by gen/gen.go.
Code generated by gen/gen.go.
call/internal/dll
Package dll provides methods for dynamically loading shared libraries and symbol lookup.
Package dll provides methods for dynamically loading shared libraries and symbol lookup.
call/internal/ffi
Package ffi provides information about the platform-native C ABI types.
Package ffi provides information about the platform-native C ABI types.
example/petstore
Package petstore serves as an example for how to represent a REST API specification.
Package petstore serves as an example for how to represent a REST API specification.
internal/http
Package http provides an extendable shell API based on http.
Package http provides an extendable shell API based on http.
internal/rtags
Package rtags provides methods for reading a rest.Tag, do not make this public, instead extend the rest.Tag with methods if required.
Package rtags provides methods for reading a rest.Tag, do not make this public, instead extend the rest.Tag with methods if required.
rest
Package rest provides a REST API transport.
Package rest provides a REST API transport.
stub
Package stub provides a stub [api.Linker] that returns empty values and specific errors.
Package stub provides a stub [api.Linker] that returns empty values and specific errors.
xray
Package xray provides standard means for introspecting the internal operational state of an [api.Linker].
Package xray provides standard means for introspecting the internal operational state of an [api.Linker].
bin
Package bin enables you to represent binary formats.
Package bin enables you to represent binary formats.
std/cpu/amd64
Package amd64 provides an instruction set specification for the AMD64 architecture.
Package amd64 provides an instruction set specification for the AMD64 architecture.
std/cpu/arm64
Package arm64 provides an instruction set specification for the ARM64 architecture.
Package arm64 provides an instruction set specification for the ARM64 architecture.
cmd
gnu
Package gnu provides specifications for GNU variants of the standard POSIX commands.
Package gnu provides specifications for GNU variants of the standard POSIX commands.
std/posix
Package posix provides a specifications for standard POSIX command-line programs.
Package posix provides a specifications for standard POSIX command-line programs.
eon
Package eon provides to represent pending asynchronous execution.
Package eon provides to represent pending asynchronous execution.
std/epoch/unix
Package unix provides standard unix time types.
Package unix provides standard unix time types.
Package jit provides a safe alternative to reflect.MakeFunc with support for transparent optimisation.
Package jit provides a safe alternative to reflect.MakeFunc with support for transparent optimisation.
Package kvs provides an interface for key-value stores.
Package kvs provides an interface for key-value stores.
Package lib provides a representation of the C standard library.
Package lib provides a representation of the C standard library.
Package mmm provides a way to manually manage memory and resource lifetimes with protections against unsafe double-free and use-after-free errors.
Package mmm provides a way to manually manage memory and resource lifetimes with protections against unsafe double-free and use-after-free errors.
Package oas provides a representation of the OpenAPI Specification (OAS) Version 3.1.0
Package oas provides a representation of the OpenAPI Specification (OAS) Version 3.1.0
Package pub provides a representation for message queuing, event handling and callback flows.
Package pub provides a representation for message queuing, event handling and callback flows.
qty
Package qty provides unit tagged quantity types for numeric values.
Package qty provides unit tagged quantity types for numeric values.
std/binary/prefix/gibi
Package gibi provides units using the 'gibi' binary prefix.
Package gibi provides units using the 'gibi' binary prefix.
std/binary/prefix/kibi
Package kibi provides units using the 'kibi' binary prefix.
Package kibi provides units using the 'kibi' binary prefix.
std/binary/prefix/mebi
Package mebi provides units using the 'mebi' binary prefix.
Package mebi provides units using the 'mebi' binary prefix.
std/currency/cents
Package cents provides tagged values for a monetary quantity of the base denomination for an implicit currency.
Package cents provides tagged values for a monetary quantity of the base denomination for an implicit currency.
std/measures
Package measures provides a set of measures for physical quantities.
Package measures provides a set of measures for physical quantities.
std/metric/prefix/centi
Package centi provides standard types to represent a hundredth of a SI unit.
Package centi provides standard types to represent a hundredth of a SI unit.
std/metric/prefix/giga
Package giga provides units based around the 'giga' metric prefix.
Package giga provides units based around the 'giga' metric prefix.
std/metric/prefix/kilo
Package kilo provides units based around the 'kilo' metric prefix.
Package kilo provides units based around the 'kilo' metric prefix.
std/metric/prefix/mega
Package mega provides standard types to represent millions for a SI unit.
Package mega provides standard types to represent millions for a SI unit.
std/metric/prefix/micro
Package micro provides provides units based around the 'micro' metric prefix.
Package micro provides provides units based around the 'micro' metric prefix.
std/metric/prefix/milli
Package milli provides provides units based around the SI 'milli' metric prefix.
Package milli provides provides units based around the SI 'milli' metric prefix.
std/metric/prefix/nano
Package nano provides provides units based around the SI 'nano' metric prefix.
Package nano provides provides units based around the SI 'nano' metric prefix.
ref
Package ref provides means for representing reference values, ie.
Package ref provides means for representing reference values, ie.
oss/license
Package license provides SPDX license identifiers.
Package license provides SPDX license identifiers.
std/email
Package email provides a RFC 5322 standard email address reference type.
Package email provides a RFC 5322 standard email address reference type.
std/media
Package media provides media type references.
Package media provides media type references.
std/uri
Package uri provides URI reference types.
Package uri provides URI reference types.
std/url
Package url provides URL reference types.
Package url provides URL reference types.
std/uuid/v4
Package uuid provides a standard UUIDv4 reference type.
Package uuid provides a standard UUIDv4 reference type.
Package rpc provides a way to expose closures over API implementation boundaries.
Package rpc provides a way to expose closures over API implementation boundaries.
sql
Package sql defines a data map type with support for type-safe structured queries.
Package sql defines a data map type with support for type-safe structured queries.
std/sodium
Package sodium provides a specification for the SODIUM standard database interface.
Package sodium provides a specification for the SODIUM standard database interface.
txt
Package txt provides text validation types, null terminated strings and a human readable textual struct tag.
Package txt provides text validation types, null terminated strings and a human readable textual struct tag.
std/human
Package human provides standard way to reference people by name.
Package human provides standard way to reference people by name.
std/markdown
Package markdown provide markdown types.
Package markdown provide markdown types.
std/src/js
Package js provides a way to represent JavaScript strings.
Package js provides a way to represent JavaScript strings.
Package xyz provides switch types, tuples and a binary sequence tag.
Package xyz provides switch types, tuples and a binary sequence tag.

Jump to

Keyboard shortcuts

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