add transport address from env variable
This commit is contained in:
parent
f5687a0094
commit
0bc3f9d170
|
@ -14,6 +14,14 @@ func (e *Error) Error() string {
|
|||
return fmt.Sprintf("code: %d, message: %s", e.Code, e.Message)
|
||||
}
|
||||
|
||||
func (e *Error) GetCode() int {
|
||||
return e.Code
|
||||
}
|
||||
|
||||
func (e *Error) GetMessage() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
func Warp(code int, err error) error {
|
||||
return &Error{
|
||||
Code: code,
|
||||
|
|
|
@ -6,7 +6,9 @@ import (
|
|||
"math"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
@ -243,6 +245,8 @@ func New(cbs ...Option) *Server {
|
|||
uri: &url.URL{Scheme: "cli"},
|
||||
router: newRouter(""),
|
||||
}
|
||||
port, _ := strconv.Atoi(os.Getenv("CLI_PORT"))
|
||||
srv.opts.address = fmt.Sprintf(":%d", port)
|
||||
for _, cb := range cbs {
|
||||
cb(srv.opts)
|
||||
}
|
||||
|
|
|
@ -2,8 +2,11 @@ package grpc
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"git.nobla.cn/golang/aeus/metadata"
|
||||
"git.nobla.cn/golang/aeus/middleware"
|
||||
|
@ -136,7 +139,6 @@ func New(cbs ...Option) *Server {
|
|||
opts: &options{
|
||||
network: "tcp",
|
||||
logger: logger.Default(),
|
||||
address: ":0",
|
||||
grpcOpts: make([]grpc.ServerOption, 0, 10),
|
||||
},
|
||||
uri: &url.URL{
|
||||
|
@ -144,6 +146,8 @@ func New(cbs ...Option) *Server {
|
|||
},
|
||||
middlewares: make([]middleware.Middleware, 0, 10),
|
||||
}
|
||||
port, _ := strconv.Atoi(os.Getenv("GRPC_PORT"))
|
||||
svr.opts.address = fmt.Sprintf(":%d", port)
|
||||
for _, cb := range cbs {
|
||||
cb(svr.opts)
|
||||
}
|
||||
|
|
|
@ -2,11 +2,14 @@ package http
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/pprof"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -242,9 +245,10 @@ func New(cbs ...Option) *Server {
|
|||
opts: &options{
|
||||
network: "tcp",
|
||||
logger: logger.Default(),
|
||||
address: ":0",
|
||||
},
|
||||
}
|
||||
port, _ := strconv.Atoi(os.Getenv("HTTP_PORT"))
|
||||
svr.opts.address = fmt.Sprintf(":%d", port)
|
||||
for _, cb := range cbs {
|
||||
cb(svr.opts)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue