Documentation
¶
Overview ¶
Package sdk is the Go SDK for building services on the platform.
A service is a self-contained backend that declares what it offers in a manifest, serves it over REST and/or gRPC, and is discovered and called by the platform and by other services. This module gives you the pieces to build one, organised one package per concern:
service serve HTTP and gRPC, with the platform conventions built in host assemble a platform host: boot order, middleware chain, health boot process startup: env, database, tracing, signals, teardown auth authenticate the caller and authorize the operation tenancy scope data to a tenant, and make the database enforce it events publish and consume domain events workflow run work that must survive a restart client call other services by (service, operation) rather than URL contracts the manifest and wire types that define the contract errors the platform error taxonomy observability structured logging and OpenTelemetry tracing
Getting started ¶
The smallest useful service is a manifest, a route, and Run:
func main() {
svc := service.New(contracts.ServiceManifest{
ID: "inventory",
Name: "Inventory",
Version: "0.1.0",
PlatformVersion: "^0.1.0",
Type: contracts.ServiceTypeAPI,
APIBaseURL: "http://inventory:8090",
})
svc.GET("item.list", "/api/v1/items", listItems)
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
if err := svc.Run(ctx, ":8090"); err != nil {
log.Fatal(err)
}
}
Each package's own documentation covers its concern in full. Start with github.com/neokarl/sdk-go/service.
Services and hosts ¶
Most of this module is for building a *service*. Two packages are for the other side of the architecture: github.com/neokarl/sdk-go/host assembles the platform host a service registers with, and github.com/neokarl/sdk-go/boot holds the startup primitives both need. Neither knows anything about any host's or service's domain.
Versioning ¶
Version is the version of this module. It is deliberately distinct from github.com/neokarl/sdk-go/contracts.Version, which is the version of the platform *contract* — the manifest shape and the rules a service must satisfy. A service declares which contract it targets via its manifest's PlatformVersion; the SDK version is just which release of this code you build against.
Index ¶
Constants ¶
const Version = "0.1.0"
Version is the semantic version of this SDK module.
It tracks the git tag this code was released under. It is not the platform contract version — see the package documentation for the distinction.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package auth is the framework's authentication surface: it verifies OIDC/JWT bearer tokens against an issuer's JWKS, for both the HTTP edge (echo middleware) and the service plane (gRPC interceptors).
|
Package auth is the framework's authentication surface: it verifies OIDC/JWT bearer tokens against an issuer's JWKS, for both the HTTP edge (echo middleware) and the service plane (gRPC interceptors). |
|
Package boot holds the process-level primitives every platform binary needs before it can do anything useful: read configuration from the environment, open the database, install tracing, and shut down cleanly on a signal.
|
Package boot holds the process-level primitives every platform binary needs before it can do anything useful: read configuration from the environment, open the database, install tracing, and shut down cleanly on a signal. |
|
Package client is how a service calls other services.
|
Package client is how a service calls other services. |
|
cmd
|
|
|
apidoc
command
Command apidoc extracts this module's public API into a JSON document, so a documentation site can render real signatures instead of hand-maintaining a table that drifts.
|
Command apidoc extracts this module's public API into a JSON document, so a documentation site can render real signatures instead of hand-maintaining a table that drifts. |
|
Package contracts holds the wire-format types the platform exposes to plugins and the frontend.
|
Package contracts holds the wire-format types the platform exposes to plugins and the frontend. |
|
Package errors defines the platform's standard error taxonomy.
|
Package errors defines the platform's standard error taxonomy. |
|
Package events is the framework's durable event bus.
|
Package events is the framework's durable event bus. |
|
examples
|
|
|
full
command
Command full is a production-shaped platform service: authentication and authorization, tenant-isolated persistence, tracing, events, and calls to peer services — wired in the order they have to be wired.
|
Command full is a production-shaped platform service: authentication and authorization, tenant-isolated persistence, tracing, events, and calls to peer services — wired in the order they have to be wired. |
|
minimal
command
Command minimal is the smallest complete platform service: a manifest, some routes, and Run.
|
Command minimal is the smallest complete platform service: a manifest, some routes, and Run. |
|
Package host assembles a platform host — the process that serves the plugin catalog, fronts the browser, and exposes the built-in services other services call.
|
Package host assembles a platform host — the process that serves the plugin catalog, fronts the browser, and exposes the built-in services other services call. |
|
internal
|
|
|
mtls
Package mtls builds mutual-TLS credentials for the gRPC service plane, so a call is both encrypted and authenticated at the channel: the server verifies the client's certificate and vice-versa.
|
Package mtls builds mutual-TLS credentials for the gRPC service plane, so a call is both encrypted and authenticated at the channel: the server verifies the client's certificate and vice-versa. |
|
Package middleware bundles the Echo middleware stack used by the API server.
|
Package middleware bundles the Echo middleware stack used by the API server. |
|
Package observability wires the two things every service needs to be debuggable in production: structured logging and distributed tracing.
|
Package observability wires the two things every service needs to be debuggable in production: structured logging and distributed tracing. |
|
Package service is the ergonomic entry point for building a platform plugin's Go backend.
|
Package service is the ergonomic entry point for building a platform plugin's Go backend. |
|
Package tenancy scopes a service's data to one tenant and makes the *database* enforce it, rather than trusting a dozen query paths to remember a WHERE clause.
|
Package tenancy scopes a service's data to one tenant and makes the *database* enforce it, rather than trusting a dozen query paths to remember a WHERE clause. |
|
Package transport propagates the caller's identity across service-to-service gRPC calls, so a downstream service knows who originated a request rather than seeing it arrive anonymous.
|
Package transport propagates the caller's identity across service-to-service gRPC calls, so a downstream service knows who originated a request rather than seeing it arrive anonymous. |
|
Package workflow runs work that must survive a restart.
|
Package workflow runs work that must survive a restart. |
|
temporal
Package temporal runs github.com/neokarl/sdk-go/workflow jobs on Temporal.
|
Package temporal runs github.com/neokarl/sdk-go/workflow jobs on Temporal. |