@@ -18,80 +18,82 @@ import (
1818 "github.com/vllm-project/semantic-router/src/semantic-router/pkg/observability/metrics"
1919)
2020
21- // MilvusConfig defines the complete configuration structure for Milvus cache backend
21+ // MilvusConfig defines the complete configuration structure for Milvus cache backend.
22+ // Fields use both json/yaml tags because sigs.k8s.io/yaml converts YAML→JSON before decoding,
23+ // so json tags ensure snake_case keys map correctly without switching parsers.
2224type MilvusConfig struct {
2325 Connection struct {
24- Host string `yaml:"host"`
25- Port int `yaml:"port"`
26- Database string `yaml:"database"`
27- Timeout int `yaml:"timeout"`
26+ Host string `json:"host" yaml:"host"`
27+ Port int `json:"port" yaml:"port"`
28+ Database string `json:"database" yaml:"database"`
29+ Timeout int `json:"timeout" yaml:"timeout"`
2830 Auth struct {
29- Enabled bool `yaml:"enabled"`
30- Username string `yaml:"username"`
31- Password string `yaml:"password"`
32- } `yaml:"auth"`
31+ Enabled bool `json:"enabled" yaml:"enabled"`
32+ Username string `json:"username" yaml:"username"`
33+ Password string `json:"password" yaml:"password"`
34+ } `json:"auth" yaml:"auth"`
3335 TLS struct {
34- Enabled bool `yaml:"enabled"`
35- CertFile string `yaml:"cert_file"`
36- KeyFile string `yaml:"key_file"`
37- CAFile string `yaml:"ca_file"`
38- } `yaml:"tls"`
39- } `yaml:"connection"`
36+ Enabled bool `json:"enabled" yaml:"enabled"`
37+ CertFile string `json:"cert_file" yaml:"cert_file"`
38+ KeyFile string `json:"key_file" yaml:"key_file"`
39+ CAFile string `json:"ca_file" yaml:"ca_file"`
40+ } `json:"tls" yaml:"tls"`
41+ } `json:"connection" yaml:"connection"`
4042 Collection struct {
41- Name string `yaml:"name"`
42- Description string `yaml:"description"`
43+ Name string `json:"name" yaml:"name"`
44+ Description string `json:"description" yaml:"description"`
4345 VectorField struct {
44- Name string `yaml:"name"`
45- Dimension int `yaml:"dimension"`
46- MetricType string `yaml:"metric_type"`
47- } `yaml:"vector_field"`
46+ Name string `json:"name" yaml:"name"`
47+ Dimension int `json:"dimension" yaml:"dimension"`
48+ MetricType string `json:"metric_type" yaml:"metric_type"`
49+ } `json:"vector_field" yaml:"vector_field"`
4850 Index struct {
49- Type string `yaml:"type"`
51+ Type string `json:"type" yaml:"type"`
5052 Params struct {
51- M int `yaml:"M"`
52- EfConstruction int `yaml:"efConstruction"`
53- } `yaml:"params"`
54- } `yaml:"index"`
55- } `yaml:"collection"`
53+ M int `json:"M" yaml:"M"`
54+ EfConstruction int `json:"efConstruction" yaml:"efConstruction"`
55+ } `json:"params" yaml:"params"`
56+ } `json:"index" yaml:"index"`
57+ } `json:"collection" yaml:"collection"`
5658 Search struct {
5759 Params struct {
58- Ef int `yaml:"ef"`
59- } `yaml:"params"`
60- TopK int `yaml:"topk"`
61- ConsistencyLevel string `yaml:"consistency_level"`
62- } `yaml:"search"`
60+ Ef int `json:"ef" yaml:"ef"`
61+ } `json:"params" yaml:"params"`
62+ TopK int `json:"topk" yaml:"topk"`
63+ ConsistencyLevel string `json:"consistency_level" yaml:"consistency_level"`
64+ } `json:"search" yaml:"search"`
6365 Performance struct {
6466 ConnectionPool struct {
65- MaxConnections int `yaml:"max_connections"`
66- MaxIdleConnections int `yaml:"max_idle_connections"`
67- AcquireTimeout int `yaml:"acquire_timeout"`
68- } `yaml:"connection_pool"`
67+ MaxConnections int `json:"max_connections" yaml:"max_connections"`
68+ MaxIdleConnections int `json:"max_idle_connections" yaml:"max_idle_connections"`
69+ AcquireTimeout int `json:"acquire_timeout" yaml:"acquire_timeout"`
70+ } `json:"connection_pool" yaml:"connection_pool"`
6971 Batch struct {
70- InsertBatchSize int `yaml:"insert_batch_size"`
71- Timeout int `yaml:"timeout"`
72- } `yaml:"batch"`
73- } `yaml:"performance"`
72+ InsertBatchSize int `json:"insert_batch_size" yaml:"insert_batch_size"`
73+ Timeout int `json:"timeout" yaml:"timeout"`
74+ } `json:"batch" yaml:"batch"`
75+ } `json:"performance" yaml:"performance"`
7476 DataManagement struct {
7577 TTL struct {
76- Enabled bool `yaml:"enabled"`
77- TimestampField string `yaml:"timestamp_field"`
78- CleanupInterval int `yaml:"cleanup_interval"`
79- } `yaml:"ttl"`
78+ Enabled bool `json:"enabled" yaml:"enabled"`
79+ TimestampField string `json:"timestamp_field" yaml:"timestamp_field"`
80+ CleanupInterval int `json:"cleanup_interval" yaml:"cleanup_interval"`
81+ } `json:"ttl" yaml:"ttl"`
8082 Compaction struct {
81- Enabled bool `yaml:"enabled"`
82- Interval int `yaml:"interval"`
83- } `yaml:"compaction"`
84- } `yaml:"data_management"`
83+ Enabled bool `json:"enabled" yaml:"enabled"`
84+ Interval int `json:"interval" yaml:"interval"`
85+ } `json:"compaction" yaml:"compaction"`
86+ } `json:"data_management" yaml:"data_management"`
8587 Logging struct {
86- Level string `yaml:"level"`
87- EnableQueryLog bool `yaml:"enable_query_log"`
88- EnableMetrics bool `yaml:"enable_metrics"`
89- } `yaml:"logging"`
88+ Level string `json:"level" yaml:"level"`
89+ EnableQueryLog bool `json:"enable_query_log" yaml:"enable_query_log"`
90+ EnableMetrics bool `json:"enable_metrics" yaml:"enable_metrics"`
91+ } `json:"logging" yaml:"logging"`
9092 Development struct {
91- DropCollectionOnStartup bool `yaml:"drop_collection_on_startup"`
92- AutoCreateCollection bool `yaml:"auto_create_collection"`
93- VerboseErrors bool `yaml:"verbose_errors"`
94- } `yaml:"development"`
93+ DropCollectionOnStartup bool `json:"drop_collection_on_startup" yaml:"drop_collection_on_startup"`
94+ AutoCreateCollection bool `json:"auto_create_collection" yaml:"auto_create_collection"`
95+ VerboseErrors bool `json:"verbose_errors" yaml:"verbose_errors"`
96+ } `json:"development" yaml:"development"`
9597}
9698
9799// MilvusCache provides a scalable semantic cache implementation using Milvus vector database
0 commit comments