123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- 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
- }
|