cmd

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 97 Imported by: 0

Documentation

Overview

Package cmd provides CLI commands for OSAPI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

type NATSClient

type NATSClient interface {
	// Connection management
	Connect() error
	Close()

	// Stream operations
	CreateOrUpdateStreamWithConfig(
		ctx context.Context,
		streamConfig jetstream.StreamConfig,
	) error
	GetStreamInfo(
		ctx context.Context,
		streamName string,
	) (*jetstream.StreamInfo, error)

	// KV operations
	CreateOrUpdateKVBucket(
		ctx context.Context,
		bucketName string,
	) (jetstream.KeyValue, error)
	CreateOrUpdateKVBucketWithConfig(
		ctx context.Context,
		config jetstream.KeyValueConfig,
	) (jetstream.KeyValue, error)

	// Object Store operations
	CreateOrUpdateObjectStore(
		ctx context.Context,
		cfg jetstream.ObjectStoreConfig,
	) (jetstream.ObjectStore, error)
	ObjectStore(
		ctx context.Context,
		name string,
	) (jetstream.ObjectStore, error)

	// Message publishing
	Publish(
		ctx context.Context,
		subject string,
		data []byte,
	) error

	// Message consumption
	ConsumeMessages(
		ctx context.Context,
		streamName string,
		consumerName string,
		handler natsclient.JetStreamMessageHandler,
		opts *natsclient.ConsumeOptions,
	) error
	CreateOrUpdateConsumerWithConfig(
		ctx context.Context,
		streamName string,
		consumerConfig jetstream.ConsumerConfig,
	) error

	// KV convenience operations
	KVPut(
		bucket string,
		key string,
		value []byte,
	) error

	// Core NATS operations (non-JetStream)
	Subscribe(
		subject string,
		handler nats.MsgHandler,
	) (*nats.Subscription, error)
	PublishCore(
		subject string,
		data []byte,
	) error

	// Connection inspection
	ConnectedURL() string
	ConnectedServerVersion() string

	// JetStream handle access
	KeyValue(
		ctx context.Context,
		bucket string,
	) (jetstream.KeyValue, error)
	Stream(
		ctx context.Context,
		name string,
	) (jetstream.Stream, error)
}

NATSClient defines the NATS operations needed by cmd setup, runtime, and metrics functions. Each function that receives a NATSClient uses only a subset of these methods; the full interface is defined here so the natsBundle can store a single value that satisfies all consumers.

type ServerManager

type ServerManager interface {
	cli.Lifecycle
	// RegisterHandlers registers a list of handlers with the Echo instance.
	RegisterHandlers(handlers []func(e *echo.Echo))
}

ServerManager responsible for Server operations.

type TokenGenerator

type TokenGenerator interface {
	Generate(
		signingKey string,
		roles []string,
		subject string,
		permissions []string,
	) (string, error)
}

TokenGenerator generates signed JWT tokens.

type TokenValidator

type TokenValidator interface {
	Validate(
		tokenString string,
		signingKey string,
	) (*authtoken.CustomClaims, error)
}

TokenValidator parses and validates JWT tokens.

Source Files

Jump to

Keyboard shortcuts

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