@@ -83,6 +83,7 @@ func GenParamEnum() {
8383 stringParamMap := make (map [string ]string )
8484 stringSliceParamMap := make (map [string ]string )
8585 intParamMap := make (map [string ]string )
86+ byteRateParamMap := make (map [string ]string )
8687 boolParamMap := make (map [string ]string )
8788 durationParamMap := make (map [string ]string )
8889 objectParamMap := make (map [string ]string )
@@ -177,8 +178,7 @@ func GenParamEnum() {
177178 case "int" :
178179 intParamMap [name ] = rawName
179180 case "byterate" :
180- // byterate is stored as int (bytes per second) internally
181- intParamMap [name ] = rawName
181+ byteRateParamMap [name ] = rawName
182182 case "bool" :
183183 boolParamMap [name ] = rawName
184184 case "duration" :
@@ -207,13 +207,14 @@ func GenParamEnum() {
207207 StringMap map [string ]string
208208 StringSliceMap map [string ]string
209209 IntMap map [string ]string
210+ ByteRateMap map [string ]string
210211 BoolMap map [string ]string
211212 DurationMap map [string ]string
212213 ObjectMap map [string ]string
213214 DeprecatedMap map [string ][]string
214215 RuntimeConfigurableMap map [string ]bool
215216 AllParamNames []string
216- }{StringMap : stringParamMap , StringSliceMap : stringSliceParamMap , IntMap : intParamMap , BoolMap : boolParamMap , DurationMap : durationParamMap , ObjectMap : objectParamMap , DeprecatedMap : deprecatedMap , RuntimeConfigurableMap : runtimeConfigurableMap , AllParamNames : allParamNames })
217+ }{StringMap : stringParamMap , StringSliceMap : stringSliceParamMap , IntMap : intParamMap , ByteRateMap : byteRateParamMap , BoolMap : boolParamMap , DurationMap : durationParamMap , ObjectMap : objectParamMap , DeprecatedMap : deprecatedMap , RuntimeConfigurableMap : runtimeConfigurableMap , AllParamNames : allParamNames })
217218
218219 if err != nil {
219220 panic (err )
@@ -370,8 +371,7 @@ func GenParamStruct() {
370371 case "int" :
371372 goType = "int"
372373 case "byterate" :
373- // byterate is parsed as string but stored as int (bytes per second)
374- goType = "int"
374+ goType = "byte_rate.ByteRate"
375375 case "bool" :
376376 goType = "bool"
377377 case "duration" :
@@ -459,6 +459,8 @@ import (
459459 "time"
460460
461461 "github.com/spf13/viper"
462+
463+ "github.com/pelicanplatform/pelican/byte_rate"
462464)
463465
464466type StringParam struct {
@@ -477,6 +479,10 @@ type IntParam struct {
477479 name string
478480}
479481
482+ type ByteRateParam struct {
483+ name string
484+ }
485+
480486type DurationParam struct {
481487 name string
482488}
@@ -604,6 +610,31 @@ func (iP IntParam) GetEnvVarName() string {
604610 return paramNameToEnvVar(iP.name)
605611}
606612
613+ func (bRP ByteRateParam) GetByteRate() byte_rate.ByteRate {
614+ config := getOrCreateConfig()
615+ switch bRP.name {
616+ case "Origin.TransferRateLimit":
617+ return config.Origin.TransferRateLimit
618+ }
619+ return 0
620+ }
621+
622+ func (bRP ByteRateParam) GetName() string {
623+ return bRP.name
624+ }
625+
626+ func (bRP ByteRateParam) IsSet() bool {
627+ return viper.IsSet(bRP.name)
628+ }
629+
630+ func (bRP ByteRateParam) IsRuntimeConfigurable() bool {
631+ return IsRuntimeConfigurable(bRP.name)
632+ }
633+
634+ func (bRP ByteRateParam) GetEnvVarName() string {
635+ return paramNameToEnvVar(bRP.name)
636+ }
637+
607638func (bP BoolParam) GetBool() bool {
608639 config := getOrCreateConfig()
609640 switch bP.name {
@@ -702,6 +733,11 @@ var ({{range $key, $value := .IntMap}}
702733 {{- end}}
703734)
704735
736+ var ({{range $key, $value := .ByteRateMap}}
737+ {{$key}} = ByteRateParam{{"{"}}{{printf "%q" $value}}{{"}"}}
738+ {{- end}}
739+ )
740+
705741var ({{range $key, $value := .BoolMap}}
706742 {{$key}} = BoolParam{{"{"}}{{printf "%q" $value}}{{"}"}}
707743 {{- end}}
@@ -741,6 +777,8 @@ package param
741777
742778import (
743779 "time"
780+
781+ "github.com/pelicanplatform/pelican/byte_rate"
744782)
745783
746784{{.GeneratedConfig}}
0 commit comments