Documentation
¶
Overview ¶
Package server provides a ready-to-use HTTP API server that can be wired with any github.com/smallfish06/krsec/pkg/broker.Broker implementation.
Use New to create a server with externally supplied broker instances, then call Server.Run to start listening. The server exposes REST endpoints for quotes, orders, accounts, instruments, and an auto-generated OpenAPI spec.
Index ¶
- func DefaultKISProxyCachePolicy(req KISProxyCacheRequest) (time.Duration, bool)
- func RunFromConfigFile(path string) error
- func RunFromConfigFileWithLogger(path string, logger *slog.Logger) error
- type Account
- type KISProxyCacheOptions
- type KISProxyCachePolicy
- type KISProxyCacheRequest
- type KISProxyRateLimitOptions
- type Options
- type Server
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.
func RunFromConfigFile ¶ added in v0.7.0
RunFromConfigFile loads a config.yaml and starts the server. This is the simplest way to embed krsec in another project.
Types ¶
type Account ¶
type Account struct {
ID string
Name string
Broker string
Sandbox bool
Credentials broker.Credentials
}
Account describes an externally supplied account/broker binding.
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
KISProxyRateLimitOptions configures outbound KIS upstream throttling.
type Options ¶
type Options struct {
Host string
Port int
Accounts []Account
Brokers map[string]broker.Broker // account_id -> broker implementation
Logger *slog.Logger // optional structured logger; nil uses slog.Default()
KISProxyCache KISProxyCacheOptions
KISProxyRateLimit KISProxyRateLimitOptions
}
Options configures the public API server. External users can provide their own broker implementations through Brokers.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps the internal HTTP server and exposes a stable public API.