package comm import "time" type RequstConfigOption struct { ReqPayload interface{} Timeout time.Duration } type ReqConfiger struct { Name string } type SetConfiger struct { Name string Value string DevValue string } func (q *NatsBus) RequestConfig(key string, timoutOption ...interface{}) (string, error) { data := &ReqConfiger{ Name: key, } timeout := 5 * time.Second for _, option := range timoutOption { if _, ok := option.(time.Duration); ok { timeout = option.(time.Duration) break } } result := "" err := q.RequestApi("request.configer", data, timeout, &result) return result, err } func (q *NatsBus) SetConfig(key string, Value string, timoutOption ...interface{}) (string, error) { data := &SetConfiger{ Name: key, Value: Value, } timeout := 5 * time.Second for _, option := range timoutOption { if _, ok := option.(time.Duration); ok { timeout = option.(time.Duration) break } } result := "" err := q.RequestApi("set.configer", data, timeout, &result) return result, err } func (q *NatsBus) SetDevConfig(key string, Value string, timoutOption ...interface{}) (string, error) { data := &SetConfiger{ Name: key, DevValue: Value, } timeout := 5 * time.Second for _, option := range timoutOption { if _, ok := option.(time.Duration); ok { timeout = option.(time.Duration) break } } result := "" err := q.RequestApi("set.configer", data, timeout, &result) return result, err } func (q *NatsBus) RequestConfigDev(key string, timoutOption ...interface{}) (string, error) { data := &ReqConfiger{ Name: key, } timeout := 5 * time.Second for _, option := range timoutOption { if _, ok := option.(time.Duration); ok { timeout = option.(time.Duration) break } } result := "" err := q.RequestApi("request.configer.dev", data, timeout, &result) return result, err }