server

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultKISProxyCachePolicy added in v0.15.0

func DefaultKISProxyCachePolicy(req KISProxyCacheRequest) (time.Duration, bool)

DefaultKISProxyCachePolicy caches public KIS quotation/reference endpoints and excludes trading, order, and auth-style endpoints.

Types

type AuthTokenRequest

type AuthTokenRequest struct {
	Broker      string             `json:"broker"`
	Credentials broker.Credentials `json:"credentials"`
	Sandbox     bool               `json:"sandbox"`
}

AuthTokenRequest represents an auth token request

type BrokerWithExtras

type BrokerWithExtras interface {
	broker.Broker
	// contains filtered or unexported methods
}

BrokerWithExtras is a test-oriented interface for server handlers.

type KISProxyCacheOptions added in v0.15.0

type KISProxyCacheOptions struct {
	Policy         KISProxyCachePolicy
	MaxEntries     int
	StaleRetention time.Duration
}

KISProxyCacheOptions configures the in-process KIS proxy cache.

type KISProxyCachePolicy added in v0.15.0

type KISProxyCachePolicy func(KISProxyCacheRequest) (time.Duration, bool)

KISProxyCachePolicy decides whether a KIS proxy request should be cached and returns its soft TTL when cacheable.

type KISProxyCacheRequest added in v0.15.0

type KISProxyCacheRequest struct {
	Method    string
	Path      string
	TRID      string
	AccountID string
	Params    map[string]string
}

KISProxyCacheRequest describes a normalized KIS proxy request for cache policy decisions. Params is a copy and can be inspected or modified by policy code.

type KISProxyRateLimitOptions added in v0.16.0

type KISProxyRateLimitOptions struct {
	Disabled          bool
	RequestsPerSecond float64
	Burst             int
	Overrides         []KISProxyRateLimitOverrideOptions
}

KISProxyRateLimitOptions configures outbound KIS upstream throttling.

type KISProxyRateLimitOverrideOptions added in v0.16.1

type KISProxyRateLimitOverrideOptions struct {
	Path              string
	TRID              string
	RequestsPerSecond float64
	Burst             int
}

type Response

type Response struct {
	OK     bool        `json:"ok"`
	Data   interface{} `json:"data,omitempty"`
	Error  string      `json:"error,omitempty"`
	Broker string      `json:"broker,omitempty"`
}

Response represents a standard API response

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents the HTTP server

func New

func New(cfg *config.Config) *Server

New creates a new server instance. This constructor wires built-in brokers from config (currently KIS, Kiwoom).

func NewWithBrokers

func NewWithBrokers(host string, port int, accounts []config.AccountConfig, brokers map[string]broker.Broker) *Server

NewWithBrokers creates a server with externally provided brokers. This constructor is used by the public pkg/server package for OSS extensibility.

func NewWithBrokersOptions added in v0.15.0

func NewWithBrokersOptions(
	host string,
	port int,
	accounts []config.AccountConfig,
	brokers map[string]broker.Broker,
	opts ServerOptions,
) *Server

func NewWithLogger added in v0.13.0

func NewWithLogger(cfg *config.Config, logger *slog.Logger) *Server

NewWithLogger creates a new server instance with a custom logger.

func (*Server) App

func (s *Server) App() *fuego.Server

App returns the underlying Fuego server for embedding/customization.

func (*Server) Run

func (s *Server) Run() error

Run starts the HTTP server

type ServerOptions added in v0.15.0

type ServerOptions struct {
	Logger            *slog.Logger
	KISProxyCache     KISProxyCacheOptions
	KISProxyRateLimit KISProxyRateLimitOptions
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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