types

package
v1.0.0-alpha.59 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 3 Imported by: 0

README

Types Package

Shared domain types used across the SemStreams platform to avoid circular dependencies.

Purpose

This package provides foundational types that multiple packages need to reference. By placing these types in a low-level package with minimal dependencies, we break circular import chains between higher-level packages like config, component, and service.

Design Principles

  1. Minimal dependencies - Only imports pkg/errs and standard library
  2. No sub-packages - Flat structure keeps the dependency graph simple
  3. Pure domain types - Configuration structures and enums, no business logic
  4. Shared contracts - Types used by multiple packages to communicate

Types

ComponentType

Enumeration of component categories in the processing pipeline:

const (
    ComponentTypeInput     ComponentType = "input"
    ComponentTypeProcessor ComponentType = "processor"
    ComponentTypeOutput    ComponentType = "output"
    ComponentTypeStorage   ComponentType = "storage"
    ComponentTypeGateway   ComponentType = "gateway"
)
ComponentConfig

Configuration structure for component instances, shared between config and component packages:

type ComponentConfig struct {
    Type    ComponentType   `json:"type"`    // Component category
    Name    string          `json:"name"`    // Factory name (e.g., "udp", "websocket")
    Enabled bool            `json:"enabled"` // Runtime enable/disable
    Config  json.RawMessage `json:"config"`  // Component-specific configuration
}
ServiceConfig

Configuration structure for service instances:

type ServiceConfig struct {
    Name    string          `json:"name"`    // Service identifier
    Enabled bool            `json:"enabled"` // Runtime enable/disable
    Config  json.RawMessage `json:"config"`  // Service-specific configuration
}
PlatformMeta

Platform identity information decoupled from config structures:

type PlatformMeta struct {
    Org      string // Organization namespace (e.g., "c360")
    Platform string // Platform identifier (e.g., "platform1")
}

Usage

import "github.com/c360/semstreams/types"

// Component configuration
cfg := types.ComponentConfig{
    Type:    types.ComponentTypeProcessor,
    Name:    "json_filter",
    Enabled: true,
    Config:  json.RawMessage(`{"field": "status"}`),
}

if err := cfg.Validate(); err != nil {
    // Handle validation error
}

// Service configuration
svcCfg := types.ServiceConfig{
    Name:    "metrics",
    Enabled: true,
}

Import Graph

pkg/errs (leaf package)
    ↑
  types (this package)
    ↑
  ┌──┴──┐
config  component  service  ...

This package sits just above pkg/errs in the dependency hierarchy, allowing it to be imported by most other packages without creating cycles.

Documentation

Overview

Package types contains shared domain types used across the semstreams platform

Package types contains shared domain types used across the semstreams platform

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComponentConfig

type ComponentConfig struct {
	Type    ComponentType   `json:"type"`    // Component type (input/processor/output/storage/gateway)
	Name    string          `json:"name"`    // Factory/component name (e.g., "udp", "websocket", "mavlink")
	Enabled bool            `json:"enabled"` // Whether component is enabled
	Config  json.RawMessage `json:"config"`  // Component-specific configuration
}

ComponentConfig provides configuration for creating a component instance The instance name comes from the map key in the components configuration. This structure is shared between the config and component packages.

func (ComponentConfig) Validate

func (c ComponentConfig) Validate() error

Validate ensures the component configuration is valid

type ComponentType

type ComponentType string

ComponentType represents the category of a component

const (
	ComponentTypeInput     ComponentType = "input"
	ComponentTypeProcessor ComponentType = "processor"
	ComponentTypeOutput    ComponentType = "output"
	ComponentTypeStorage   ComponentType = "storage"
	ComponentTypeGateway   ComponentType = "gateway"
)

Component type constants

func (ComponentType) String

func (ct ComponentType) String() string

String implements fmt.Stringer for ComponentType

type PlatformMeta

type PlatformMeta struct {
	Org      string // Organization namespace (e.g., "c360", "noaa")
	Platform string // Platform identifier (e.g., "platform1", "vessel-alpha")
}

PlatformMeta provides platform identity to services and components. This structure decouples platform identity from the config package, allowing services to access org and platform information without creating dependencies on configuration structures.

type ServiceConfig

type ServiceConfig struct {
	Name    string          `json:"name"`    // Service name (redundant with map key but useful for validation)
	Enabled bool            `json:"enabled"` // Whether service is enabled at runtime
	Config  json.RawMessage `json:"config"`  // Service-specific configuration
}

ServiceConfig provides configuration for creating a service instance. This standardizes service configuration similar to ComponentConfig, providing metadata (name, enabled) separate from service-specific config.

func (ServiceConfig) Validate

func (s ServiceConfig) Validate() error

Validate ensures the service configuration is valid

type ServiceConfigs

type ServiceConfigs map[string]ServiceConfig

ServiceConfigs holds service instance configurations. The map key is the service name (e.g., "metrics", "discovery"). Services are only created if both: 1. They have registered a constructor via init() 2. They have an entry in this config map with enabled=true

Jump to

Keyboard shortcuts

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