Add web and update deps
This commit is contained in:
parent
49f669df66
commit
d2857a7b16
15
go.mod
15
go.mod
@ -1,16 +1,21 @@
|
||||
module github.com/micro/go-micro
|
||||
|
||||
require (
|
||||
contrib.go.opencensus.io/exporter/stackdriver v0.12.1 // indirect
|
||||
github.com/BurntSushi/toml v0.3.1
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190603120859-57a2ce229fb6 // indirect
|
||||
github.com/apache/arrow/go/arrow v0.0.0-20190603170535-cdedd85f9c85 // indirect
|
||||
github.com/beevik/ntp v0.2.0
|
||||
github.com/bitly/go-simplejson v0.5.0
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668
|
||||
github.com/bwmarrin/discordgo v0.19.0
|
||||
github.com/coreos/etcd v3.3.13+incompatible
|
||||
github.com/emicklei/go-restful v2.9.6+incompatible // indirect
|
||||
github.com/forestgiant/sliceutil v0.0.0-20160425183142-94783f95db6c
|
||||
github.com/fsnotify/fsnotify v1.4.7
|
||||
github.com/fsouza/go-dockerclient v1.4.1
|
||||
github.com/ghodss/yaml v1.0.0
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-log/log v0.1.0
|
||||
github.com/go-redsync/redsync v1.2.0
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
|
||||
@ -28,24 +33,29 @@ require (
|
||||
github.com/joncalhoun/qson v0.0.0-20170526102502-8a9cab3a62b1
|
||||
github.com/json-iterator/go v1.1.6
|
||||
github.com/lucas-clemente/quic-go v0.11.2
|
||||
github.com/marten-seemann/qtls v0.2.4 // indirect
|
||||
github.com/micro/cli v0.2.0
|
||||
github.com/micro/examples v0.1.0
|
||||
github.com/micro/go-log v0.1.0
|
||||
github.com/micro/go-plugins v1.1.0
|
||||
github.com/micro/go-web v1.0.0
|
||||
github.com/micro/mdns v0.1.0
|
||||
github.com/micro/micro v1.3.0
|
||||
github.com/micro/util v0.2.0
|
||||
github.com/mitchellh/hashstructure v1.0.0
|
||||
github.com/nats-io/nats-streaming-server v0.14.3 // indirect
|
||||
github.com/nats-io/nats.go v1.7.2
|
||||
github.com/nlopes/slack v0.5.0
|
||||
github.com/pborman/uuid v1.2.0
|
||||
github.com/pkg/errors v0.8.1
|
||||
github.com/smartystreets/assertions v1.0.0 // indirect
|
||||
go.etcd.io/etcd v3.3.13+incompatible
|
||||
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5
|
||||
golang.org/x/mod v0.1.0 // indirect
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65
|
||||
golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed // indirect
|
||||
golang.org/x/tools v0.0.0-20190603152906-08e0b306e832 // indirect
|
||||
golang.org/x/tools v0.0.0-20190603181926-178e83bc9d6a // indirect
|
||||
gonum.org/v1/gonum v0.0.0-20190602094245-c4a599f7b712 // indirect
|
||||
google.golang.org/genproto v0.0.0-20190530194941-fb225487d101
|
||||
google.golang.org/grpc v1.21.0
|
||||
gopkg.in/go-playground/validator.v9 v9.29.0
|
||||
@ -53,6 +63,9 @@ require (
|
||||
gopkg.in/src-d/go-git.v4 v4.11.0
|
||||
gopkg.in/telegram-bot-api.v4 v4.6.4
|
||||
honnef.co/go/tools v0.0.0-20190602125119-5a4a2f4a438d // indirect
|
||||
k8s.io/api v0.0.0-20190602205700-9b8cae951d65 // indirect
|
||||
k8s.io/apimachinery v0.0.0-20190602183612-63a6072eb563 // indirect
|
||||
k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208 // indirect
|
||||
)
|
||||
|
||||
exclude (
|
||||
|
26
go.sum
26
go.sum
@ -28,11 +28,13 @@ contrib.go.opencensus.io/exporter/stackdriver v0.9.2/go.mod h1:QUT4zIQm95ItO2Cy7
|
||||
contrib.go.opencensus.io/exporter/stackdriver v0.10.1/go.mod h1:aX6wdwcO6bNSCDtnHBthppqGDvgg2XCcHb9K8UhckAo=
|
||||
contrib.go.opencensus.io/exporter/stackdriver v0.11.0/go.mod h1:hA7rlmtavV03FGxzWXAPBUnZeZBhWN/QYQAuMtxc9Bk=
|
||||
contrib.go.opencensus.io/exporter/stackdriver v0.12.0/go.mod h1:nDPyhzW+GXyxrKsf328j/HLDYHMypbVlKSZOtl8CCDM=
|
||||
contrib.go.opencensus.io/exporter/stackdriver v0.12.1/go.mod h1:iwB6wGarfphGGe/e5CWqyUk/cLzKnWsOKPVW3no6OTw=
|
||||
contrib.go.opencensus.io/integrations/ocsql v0.1.2/go.mod h1:8DsSdjz3F+APR+0z0WkU1aRorQCFfRxvqjUUPMbF3fE=
|
||||
contrib.go.opencensus.io/integrations/ocsql v0.1.3/go.mod h1:8DsSdjz3F+APR+0z0WkU1aRorQCFfRxvqjUUPMbF3fE=
|
||||
contrib.go.opencensus.io/integrations/ocsql v0.1.4/go.mod h1:8DsSdjz3F+APR+0z0WkU1aRorQCFfRxvqjUUPMbF3fE=
|
||||
contrib.go.opencensus.io/resource v0.0.0-20190131005048-21591786a5e0/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA=
|
||||
contrib.go.opencensus.io/resource v0.1.0/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA=
|
||||
contrib.go.opencensus.io/resource v0.1.1/go.mod h1:F361eGI91LCmW1I/Saf+rX0+OFcigGlFvXwEGEnkRLA=
|
||||
dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU=
|
||||
dmitri.shuralyov.com/app/changes v0.0.0-20181114035150-5af16e21babb/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU=
|
||||
dmitri.shuralyov.com/app/changes v0.0.0-20190324224104-4ceb812fd96a/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU=
|
||||
@ -175,6 +177,7 @@ github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190329064014-6e358769c32a/go.mod
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190404024044-fa20eadc7680/go.mod h1:T9M45xf79ahXVelWoOBmH0y4aC1t5kXO5BxwyakgIGA=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190412020505-60e2075261b6/go.mod h1:T9M45xf79ahXVelWoOBmH0y4aC1t5kXO5BxwyakgIGA=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190531090255-da3a70fec85f/go.mod h1:myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ=
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190603120859-57a2ce229fb6/go.mod h1:myCDvQSzCW+wB1WAlocEru4wMGJxy+vlxHdhegi1CDQ=
|
||||
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
|
||||
github.com/aliyun/aliyun-oss-go-sdk v1.9.8/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
|
||||
github.com/anacrolix/envpprof v0.0.0-20180404065416-323002cec2fa/go.mod h1:KgHhUaQMc8cC0+cEflSgCFNFbKwi5h54gqtVn8yhP7c=
|
||||
@ -199,6 +202,7 @@ github.com/apache/arrow/go/arrow v0.0.0-20190315010344-548e1949d527/go.mod h1:Gj
|
||||
github.com/apache/arrow/go/arrow v0.0.0-20190405001043-449530509241/go.mod h1:hSfqYaVcWAXpLRM2R4x/dsonpVt20ACXDXM3Mow8jTg=
|
||||
github.com/apache/arrow/go/arrow v0.0.0-20190426170622-338c62a2a205/go.mod h1:W8yIftLTH1FLJvxuZc4tFnIlZ2tWg7RCoJR1HcETAso=
|
||||
github.com/apache/arrow/go/arrow v0.0.0-20190531152918-dbeab70863c4/go.mod h1:NG5SvIQXIxzJR5lGmoXTX9R/EmkArKbPPFu0DUFSz10=
|
||||
github.com/apache/arrow/go/arrow v0.0.0-20190603170535-cdedd85f9c85/go.mod h1:NG5SvIQXIxzJR5lGmoXTX9R/EmkArKbPPFu0DUFSz10=
|
||||
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
|
||||
github.com/apex/log v1.1.0/go.mod h1:yA770aXIDQrhVOIGurT/pVdfCpSq1GQV/auzMN5fzvY=
|
||||
github.com/araddon/gou v0.0.0-20190110011759-c797efecbb61/go.mod h1:ikc1XA58M+Rx7SEbf0bLJCfBkwayZ8T5jBo5FXK8Uz8=
|
||||
@ -247,6 +251,7 @@ github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+Ce
|
||||
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bifurcation/mint v0.0.0-20180715133206-93c51c6ce115/go.mod h1:zVt7zX3K/aDCk9Tj+VM7YymsX66ERvzCJzw8rFCX2JU=
|
||||
github.com/bifurcation/mint v0.0.0-20190129141059-83ba9bc2ead9/go.mod h1:zVt7zX3K/aDCk9Tj+VM7YymsX66ERvzCJzw8rFCX2JU=
|
||||
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
|
||||
github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y=
|
||||
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
|
||||
@ -256,6 +261,7 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4Yn
|
||||
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
|
||||
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
|
||||
github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
|
||||
github.com/bouk/httprouter v0.0.0-20160817010721-ee8b3818a7f5/go.mod h1:CDReaxg1cmLrtcasZy43l4EYPAknXLiQSrb7tLw5zXM=
|
||||
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
|
||||
github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668 h1:U/lr3Dgy4WK+hNk4tyD+nuGjpVLPEHuJSFXMw11/HPA=
|
||||
@ -393,6 +399,7 @@ github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb
|
||||
github.com/emicklei/go-restful v2.8.1+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/emicklei/go-restful v2.9.3+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/emicklei/go-restful v2.9.6+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
|
||||
github.com/emirpasic/gods v1.9.0 h1:rUF4PuzEjMChMiNsVjdI+SyLu7rEqpQ5reNFnhC7oFo=
|
||||
github.com/emirpasic/gods v1.9.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
|
||||
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
|
||||
@ -439,6 +446,7 @@ github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gin-contrib/sse v0.0.0-20190125020943-a7658810eb74/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
|
||||
github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.3.0/go.mod h1:7cKuhb5qV2ggCFctp2fJQ+ErvciLZrIeoOSOm6mUr7Y=
|
||||
github.com/gin-gonic/gin v1.4.0/go.mod h1:OW2EZn3DO8Ln9oIKOvM++LBO+5UPHJJDH72/q/3rZdM=
|
||||
github.com/gliderlabs/ssh v0.1.1 h1:j3L6gSLQalDETeEg/Jg0mGY0/y/N6zI2xX1978P0Uqw=
|
||||
@ -948,6 +956,8 @@ github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN
|
||||
github.com/mailru/easyjson v0.0.0-20190403194419-1ea4449da983/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/marten-seemann/qtls v0.2.3 h1:0yWJ43C62LsZt08vuQJDK1uC1czUc3FJeCLPoNAI4vA=
|
||||
github.com/marten-seemann/qtls v0.2.3/go.mod h1:xzjG7avBwGGbdZ8dTGxlBnLArsVKLvwmjgmPuiQEcYk=
|
||||
github.com/marten-seemann/qtls v0.2.4 h1:mCJ6i1jAqcsm9XODrSGvXECodoAb1STta+TkxJCwCnE=
|
||||
github.com/marten-seemann/qtls v0.2.4/go.mod h1:xzjG7avBwGGbdZ8dTGxlBnLArsVKLvwmjgmPuiQEcYk=
|
||||
github.com/mattbaird/elastigo v0.0.0-20170123220020-2fe47fd29e4b/go.mod h1:5MWrJXKRQyhQdUCF+vu6U5c4nQpg70vW3eHaU0/AYbU=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
@ -1023,6 +1033,7 @@ github.com/micro/go-rcache v0.2.0/go.mod h1:EoiTwbY2ubQ6lc3ScV+SnmKbelDzeFezDxPD
|
||||
github.com/micro/go-rcache v0.2.1/go.mod h1:aPCNY3RbjBdyd6ShLENl4MDSgpAiWIU4LyNLE9+TOEo=
|
||||
github.com/micro/go-rcache v0.3.0/go.mod h1:M5zEP6UW8YfsaHHyFdcgTzgIshTPNqMKw38Mwc+ht4g=
|
||||
github.com/micro/go-web v0.6.0/go.mod h1:d7+RTjvq5mvsIq55hq1/84kbYBbvJKrcUcBxBbQR5Nc=
|
||||
github.com/micro/go-web v1.0.0 h1:gIiRVVuVWTZIKDlJxhoDr6/uRxegQmKRTsVTILaN/cc=
|
||||
github.com/micro/go-web v1.0.0/go.mod h1:d7+RTjvq5mvsIq55hq1/84kbYBbvJKrcUcBxBbQR5Nc=
|
||||
github.com/micro/h2c v1.0.0/go.mod h1:54sOOQW/GRlHhH43vKwOhUb+kHaXhVxR0d3CJhn9alE=
|
||||
github.com/micro/hipchat v0.0.0-20160328000638-4c67119ac956/go.mod h1:9LPnmAqs2JarMBCqn4eUNkATVCsGQFphxNoQEi28uLU=
|
||||
@ -1109,6 +1120,7 @@ github.com/nats-io/nats-streaming-server v0.11.2/go.mod h1:RyqtDJZvMZO66YmyjIYdI
|
||||
github.com/nats-io/nats-streaming-server v0.12.0/go.mod h1:RyqtDJZvMZO66YmyjIYdIvS69zu/wDAkyNWa8PIUa5c=
|
||||
github.com/nats-io/nats-streaming-server v0.12.2/go.mod h1:RyqtDJZvMZO66YmyjIYdIvS69zu/wDAkyNWa8PIUa5c=
|
||||
github.com/nats-io/nats-streaming-server v0.14.2/go.mod h1:RyqtDJZvMZO66YmyjIYdIvS69zu/wDAkyNWa8PIUa5c=
|
||||
github.com/nats-io/nats-streaming-server v0.14.3/go.mod h1:RyqtDJZvMZO66YmyjIYdIvS69zu/wDAkyNWa8PIUa5c=
|
||||
github.com/nats-io/nats.go v1.7.2 h1:rUV2n05Quwp0dJsnKyaL/KMBb8b50h8dBpQPaxQhtQE=
|
||||
github.com/nats-io/nats.go v1.7.2/go.mod h1:yo+8b7YsyprMCRao9okCBtz4Gfr9nSmu5vdOjuV27BE=
|
||||
github.com/nats-io/nkeys v0.0.2 h1:+qM7QpgXnvDDixitZtQUBDY9w/s9mu1ghS+JIbsrx6M=
|
||||
@ -1127,6 +1139,7 @@ github.com/oklog/run v0.0.0-20180308005104-6934b124db28/go.mod h1:dlhp/R75TPv97u
|
||||
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
|
||||
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
|
||||
github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||
github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
|
||||
github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
@ -1182,6 +1195,7 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
||||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||
github.com/pkg/profile v1.3.0/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||
github.com/pkg/term v0.0.0-20180730021639-bffc007b7fd5/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=
|
||||
github.com/pkg/term v0.0.0-20190109203006-aa71e9d9e942/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ=
|
||||
github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
@ -1191,6 +1205,7 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr
|
||||
github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E=
|
||||
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA=
|
||||
github.com/pquerna/otp v1.1.0/go.mod h1:Zad1CMQfSQZI5KLpahDiSUX4tMMREnXw98IvL1nhgMk=
|
||||
github.com/pquerna/otp v1.2.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
|
||||
github.com/prometheus/client_golang v0.0.0-20171201122222-661e31bf844d/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.0.0-20180328130430-f504d69affe1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||
@ -1270,6 +1285,7 @@ github.com/shirou/gopsutil v0.0.0-20181107111621-48177ef5f880/go.mod h1:5b4v6he4
|
||||
github.com/shirou/gopsutil v2.18.12+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc=
|
||||
github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY=
|
||||
github.com/shurcooL/component v0.0.0-20190503025225-90263df59ff6/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY=
|
||||
github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM=
|
||||
github.com/shurcooL/events v0.0.0-20190403073608-99a35243dbf4/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM=
|
||||
github.com/shurcooL/github_flavored_markdown v0.0.0-20181002035957-2122de532470/go.mod h1:2dOwnU2uBioM+SGy2aZoq1f/Sd1l9OkAeAUvjSyvgU0=
|
||||
@ -1293,10 +1309,12 @@ github.com/shurcooL/htmlg v0.0.0-20170918183704-d01228ac9e50/go.mod h1:zPn1wHpTI
|
||||
github.com/shurcooL/htmlg v0.0.0-20190120222857-1e8a37b806f3/go.mod h1:zPn1wHpTIePGnXSHpsVPWEktKXHr6+SS6x/IKRb7cpw=
|
||||
github.com/shurcooL/htmlg v0.0.0-20190503024804-b6326af49ef6/go.mod h1:zPn1wHpTIePGnXSHpsVPWEktKXHr6+SS6x/IKRb7cpw=
|
||||
github.com/shurcooL/httperror v0.0.0-20170206035902-86b7830d14cc/go.mod h1:aYMfkZ6DWSJPJ6c4Wwz3QtW22G7mf/PEgaB9k/ik5+Y=
|
||||
github.com/shurcooL/httperror v0.0.0-20190506043526-2e76094aa70e/go.mod h1:aYMfkZ6DWSJPJ6c4Wwz3QtW22G7mf/PEgaB9k/ik5+Y=
|
||||
github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
|
||||
github.com/shurcooL/httpfs v0.0.0-20181222201310-74dc9339e414/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
|
||||
github.com/shurcooL/httpfs v0.0.0-20190527155220-6a4d4a70508b/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
|
||||
github.com/shurcooL/httpgzip v0.0.0-20180522190206-b1c53ac65af9/go.mod h1:919LwcH0M7/W4fcZ0/jy0qGght1GIhqyS/EgWGH2j5Q=
|
||||
github.com/shurcooL/httpgzip v0.0.0-20190516014818-1c7afaae1203/go.mod h1:919LwcH0M7/W4fcZ0/jy0qGght1GIhqyS/EgWGH2j5Q=
|
||||
github.com/shurcooL/issues v0.0.0-20181008053335-6292fdc1e191/go.mod h1:e2qWDig5bLteJ4fwvDAc2NHzqFEthkqn7aOZAOpj+PQ=
|
||||
github.com/shurcooL/issues v0.0.0-20190120000219-08d8dadf8acb/go.mod h1:e2qWDig5bLteJ4fwvDAc2NHzqFEthkqn7aOZAOpj+PQ=
|
||||
github.com/shurcooL/issuesapp v0.0.0-20180602232740-048589ce2241/go.mod h1:NPpHK2TI7iSaM0buivtFUc9offApnI0Alt/K8hcHy0I=
|
||||
@ -1330,6 +1348,7 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1
|
||||
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/assertions v0.0.0-20190215210624-980c5ac6f3ac/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/assertions v0.0.0-20190401211740-f487f9de1cd3/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/assertions v1.0.0/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM=
|
||||
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
|
||||
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
|
||||
github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff/go.mod h1:KSQcGKpxUMHk3nbYzs/tIBAM2iDooCn0BmttHOJEbLs=
|
||||
@ -1691,6 +1710,7 @@ golang.org/x/tools v0.0.0-20190521203540-521d6ed310dd/go.mod h1:RgjU9mgBXZiqYHBn
|
||||
golang.org/x/tools v0.0.0-20190530171427-2b03ca6e44eb/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190530215528-75312fb06703/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190603152906-08e0b306e832/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190603181926-178e83bc9d6a/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/xerrors v0.0.0-20190129162528-20feca13ea86/go.mod h1:/lyp46tcDBI65C0XC8F4d0/XVb7MT7RScVRech7dX/4=
|
||||
golang.org/x/xerrors v0.0.0-20190212162355-a5947ffaace3/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190315151331-d61658bd2e18/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@ -1702,6 +1722,7 @@ gonum.org/v1/gonum v0.0.0-20190314102406-9182d211c6c2/go.mod h1:2ltnJ7xHfj0zHS40
|
||||
gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
|
||||
gonum.org/v1/gonum v0.0.0-20190403090810-169ee079a3fc/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
|
||||
gonum.org/v1/gonum v0.0.0-20190520094443-a5f8f3a4840b/go.mod h1:zXcK6UmEkbNk22MqyPrZPx3T6fsE/O56XzkDfeYUF+Y=
|
||||
gonum.org/v1/gonum v0.0.0-20190602094245-c4a599f7b712/go.mod h1:zXcK6UmEkbNk22MqyPrZPx3T6fsE/O56XzkDfeYUF+Y=
|
||||
gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
|
||||
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
|
||||
gonum.org/v1/netlib v0.0.0-20190314102120-fc220b4194ca/go.mod h1:HtmWMIgmX0AAq9G6qwzC9jvu1967JZcewWVFn32Ojy4=
|
||||
@ -1784,6 +1805,7 @@ gopkg.in/check.v1 v1.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fatih/pool.v2 v2.0.0/go.mod h1:8xVGeu1/2jr2wm5V9SPuMht2H5AEmf5aFMGSQixtjTY=
|
||||
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||
@ -1872,6 +1894,7 @@ k8s.io/api v0.0.0-20190327184913-92d2ee7fc726/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j
|
||||
k8s.io/api v0.0.0-20190405172450-8fc60343b75c/go.mod h1:3Wzsx7slWzBw6GbPMeksreuwqpC7UoolhqORRc9g5XY=
|
||||
k8s.io/api v0.0.0-20190409092523-d687e77c8ae9/go.mod h1:FQEUn50aaytlU65qqBn/w+5ugllHwrBzKm7DzbnXdzE=
|
||||
k8s.io/api v0.0.0-20190531161417-40a36c6fb216/go.mod h1:d5u8CK3NOXNN6UzOSp9m83FYJ1dZS6IX5KwNAEFM7Go=
|
||||
k8s.io/api v0.0.0-20190602205700-9b8cae951d65/go.mod h1:03pQc5o/sznCJkBfM5JE6PDBnpHKi/bUmvwz1jotxkE=
|
||||
k8s.io/apimachinery v0.0.0-20180821005732-488889b0007f/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
|
||||
k8s.io/apimachinery v0.0.0-20181127025237-2b1284ed4c93/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
|
||||
k8s.io/apimachinery v0.0.0-20190119020841-d41becfba9ee/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
|
||||
@ -1885,6 +1908,8 @@ k8s.io/apimachinery v0.0.0-20190405172352-ba051b3c4d9d/go.mod h1:ELqXqns4PTTzr6t
|
||||
k8s.io/apimachinery v0.0.0-20190409092423-760d1845f48b/go.mod h1:FW86P8YXVLsbuplGMZeb20J3jYHscrDqw4jELaFJvRU=
|
||||
k8s.io/apimachinery v0.0.0-20190531025030-97c9a3e58b4c/go.mod h1:u/2VL7tgEMV0FFTV9q0JO+7cnTsV44LP8Pmx41R4AQ4=
|
||||
k8s.io/apimachinery v0.0.0-20190531161113-d9689afd32c1/go.mod h1:u/2VL7tgEMV0FFTV9q0JO+7cnTsV44LP8Pmx41R4AQ4=
|
||||
k8s.io/apimachinery v0.0.0-20190602113612-63a6072eb563/go.mod h1:u/2VL7tgEMV0FFTV9q0JO+7cnTsV44LP8Pmx41R4AQ4=
|
||||
k8s.io/apimachinery v0.0.0-20190602183612-63a6072eb563/go.mod h1:u/2VL7tgEMV0FFTV9q0JO+7cnTsV44LP8Pmx41R4AQ4=
|
||||
k8s.io/client-go v2.0.0-alpha.0.0.20190126161006-6134db91200e+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
|
||||
k8s.io/client-go v8.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
|
||||
k8s.io/client-go v10.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
|
||||
@ -1902,6 +1927,7 @@ k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH
|
||||
k8s.io/kube-openapi v0.0.0-20190306001800-15615b16d372/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc=
|
||||
k8s.io/kube-openapi v0.0.0-20190401085232-94e1e7b7574c/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc=
|
||||
k8s.io/kube-openapi v0.0.0-20190530181030-b52b5b0f5a7c/go.mod h1:nfDlWeOsu3pUf4yWGL+ERqohP4YsZcBJXWMK+gkzOA4=
|
||||
k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208/go.mod h1:nfDlWeOsu3pUf4yWGL+ERqohP4YsZcBJXWMK+gkzOA4=
|
||||
k8s.io/utils v0.0.0-20190129030815-ed37f7428a91/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
|
||||
k8s.io/utils v0.0.0-20190131231213-4ae6e769426e/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
|
||||
k8s.io/utils v0.0.0-20190204185745-a326ccf4f02b/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
|
||||
|
@ -7,14 +7,14 @@ import (
|
||||
"net"
|
||||
|
||||
"github.com/micro/go-micro/transport"
|
||||
maddr "github.com/micro/util/go/lib/addr"
|
||||
mnet "github.com/micro/util/go/lib/net"
|
||||
mls "github.com/micro/util/go/lib/tls"
|
||||
maddr "github.com/micro/go-micro/util/addr"
|
||||
mnet "github.com/micro/go-micro/util/net"
|
||||
mls "github.com/micro/go-micro/util/tls"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials"
|
||||
|
||||
pb "github.com/micro/go-plugins/transport/grpc/proto"
|
||||
pb "github.com/micro/go-micro/transport/grpc/proto"
|
||||
)
|
||||
|
||||
type grpcTransport struct {
|
||||
|
@ -3,9 +3,9 @@ package grpc
|
||||
import (
|
||||
"runtime/debug"
|
||||
|
||||
"github.com/micro/go-log"
|
||||
"github.com/micro/go-micro/transport"
|
||||
pb "github.com/micro/go-plugins/transport/grpc/proto"
|
||||
pb "github.com/micro/go-micro/transport/grpc/proto"
|
||||
"github.com/micro/go-micro/util/log"
|
||||
"google.golang.org/grpc/peer"
|
||||
)
|
||||
|
||||
|
@ -1,20 +1,13 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: github.com/micro/go-plugins/transport/grpc/proto/transport.proto
|
||||
// source: go-micro/transport/grpc/proto/transport.proto
|
||||
|
||||
/*
|
||||
Package go_micro_grpc_transport is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
github.com/micro/go-plugins/transport/grpc/proto/transport.proto
|
||||
|
||||
It has these top-level messages:
|
||||
Message
|
||||
*/
|
||||
package go_micro_grpc_transport
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
import (
|
||||
context "context"
|
||||
@ -31,7 +24,7 @@ var _ = math.Inf
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
@ -114,7 +107,7 @@ type TransportHandler interface {
|
||||
Stream(context.Context, Transport_StreamStream) error
|
||||
}
|
||||
|
||||
func RegisterTransportHandler(s server.Server, hdlr TransportHandler, opts ...server.HandlerOption) {
|
||||
func RegisterTransportHandler(s server.Server, hdlr TransportHandler, opts ...server.HandlerOption) error {
|
||||
type transport interface {
|
||||
Stream(ctx context.Context, stream server.Stream) error
|
||||
}
|
||||
@ -122,7 +115,7 @@ func RegisterTransportHandler(s server.Server, hdlr TransportHandler, opts ...se
|
||||
transport
|
||||
}
|
||||
h := &transportHandler{hdlr}
|
||||
s.Handle(s.NewHandler(&Transport{h}, opts...))
|
||||
return s.Handle(s.NewHandler(&Transport{h}, opts...))
|
||||
}
|
||||
|
||||
type transportHandler struct {
|
||||
|
@ -1,24 +1,14 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: github.com/micro/go-plugins/transport/grpc/proto/transport.proto
|
||||
// source: go-micro/transport/grpc/proto/transport.proto
|
||||
|
||||
/*
|
||||
Package go_micro_grpc_transport is a generated protocol buffer package.
|
||||
|
||||
It is generated from these files:
|
||||
github.com/micro/go-plugins/transport/grpc/proto/transport.proto
|
||||
|
||||
It has these top-level messages:
|
||||
Message
|
||||
*/
|
||||
package go_micro_grpc_transport
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
import (
|
||||
context "golang.org/x/net/context"
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
grpc "google.golang.org/grpc"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@ -30,17 +20,40 @@ var _ = math.Inf
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type Message struct {
|
||||
Header map[string]string `protobuf:"bytes,1,rep,name=header" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
|
||||
Header map[string]string `protobuf:"bytes,1,rep,name=header,proto3" json:"header,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
|
||||
Body []byte `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Message) Reset() { *m = Message{} }
|
||||
func (m *Message) String() string { return proto.CompactTextString(m) }
|
||||
func (*Message) ProtoMessage() {}
|
||||
func (*Message) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
|
||||
func (*Message) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_29b90b9ccd5e0da5, []int{0}
|
||||
}
|
||||
|
||||
func (m *Message) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_Message.Unmarshal(m, b)
|
||||
}
|
||||
func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_Message.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (m *Message) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Message.Merge(m, src)
|
||||
}
|
||||
func (m *Message) XXX_Size() int {
|
||||
return xxx_messageInfo_Message.Size(m)
|
||||
}
|
||||
func (m *Message) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Message.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Message proto.InternalMessageInfo
|
||||
|
||||
func (m *Message) GetHeader() map[string]string {
|
||||
if m != nil {
|
||||
@ -58,6 +71,29 @@ func (m *Message) GetBody() []byte {
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Message)(nil), "go.micro.grpc.transport.Message")
|
||||
proto.RegisterMapType((map[string]string)(nil), "go.micro.grpc.transport.Message.HeaderEntry")
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("go-micro/transport/grpc/proto/transport.proto", fileDescriptor_29b90b9ccd5e0da5)
|
||||
}
|
||||
|
||||
var fileDescriptor_29b90b9ccd5e0da5 = []byte{
|
||||
// 214 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4d, 0xcf, 0xd7, 0xcd,
|
||||
0xcd, 0x4c, 0x2e, 0xca, 0xd7, 0x2f, 0x29, 0x4a, 0xcc, 0x2b, 0x2e, 0xc8, 0x2f, 0x2a, 0xd1, 0x4f,
|
||||
0x2f, 0x2a, 0x48, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0x41, 0x12, 0xd4, 0x03, 0xf3, 0x85, 0xc4, 0xd3,
|
||||
0xf3, 0xf5, 0xc0, 0xca, 0xf5, 0x40, 0x8a, 0xf4, 0xe0, 0xd2, 0x4a, 0xf3, 0x18, 0xb9, 0xd8, 0x7d,
|
||||
0x53, 0x8b, 0x8b, 0x13, 0xd3, 0x53, 0x85, 0x5c, 0xb8, 0xd8, 0x32, 0x52, 0x13, 0x53, 0x52, 0x8b,
|
||||
0x24, 0x18, 0x15, 0x98, 0x35, 0xb8, 0x8d, 0x74, 0xf4, 0x70, 0xe8, 0xd2, 0x83, 0xea, 0xd0, 0xf3,
|
||||
0x00, 0x2b, 0x77, 0xcd, 0x2b, 0x29, 0xaa, 0x0c, 0x82, 0xea, 0x15, 0x12, 0xe2, 0x62, 0x49, 0xca,
|
||||
0x4f, 0xa9, 0x94, 0x60, 0x52, 0x60, 0xd4, 0xe0, 0x09, 0x02, 0xb3, 0xa5, 0x2c, 0xb9, 0xb8, 0x91,
|
||||
0x94, 0x0a, 0x09, 0x70, 0x31, 0x67, 0xa7, 0x56, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x06, 0x81,
|
||||
0x98, 0x42, 0x22, 0x5c, 0xac, 0x65, 0x89, 0x39, 0xa5, 0xa9, 0x60, 0x5d, 0x9c, 0x41, 0x10, 0x8e,
|
||||
0x15, 0x93, 0x05, 0xa3, 0x51, 0x3c, 0x17, 0x67, 0x08, 0xcc, 0x5e, 0xa1, 0x20, 0x2e, 0xb6, 0xe0,
|
||||
0x92, 0xa2, 0xd4, 0xc4, 0x5c, 0x21, 0x05, 0x42, 0x6e, 0x93, 0x22, 0xa8, 0x42, 0x89, 0x41, 0x83,
|
||||
0xd1, 0x80, 0x31, 0x89, 0x0d, 0x1c, 0x42, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x77, 0xa1,
|
||||
0xa4, 0xcb, 0x52, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
@ -68,8 +104,9 @@ var _ grpc.ClientConn
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// Client API for Transport service
|
||||
|
||||
// TransportClient is the client API for Transport service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type TransportClient interface {
|
||||
Stream(ctx context.Context, opts ...grpc.CallOption) (Transport_StreamClient, error)
|
||||
}
|
||||
@ -83,7 +120,7 @@ func NewTransportClient(cc *grpc.ClientConn) TransportClient {
|
||||
}
|
||||
|
||||
func (c *transportClient) Stream(ctx context.Context, opts ...grpc.CallOption) (Transport_StreamClient, error) {
|
||||
stream, err := grpc.NewClientStream(ctx, &_Transport_serviceDesc.Streams[0], c.cc, "/go.micro.grpc.transport.Transport/Stream", opts...)
|
||||
stream, err := c.cc.NewStream(ctx, &_Transport_serviceDesc.Streams[0], "/go.micro.grpc.transport.Transport/Stream", opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -113,8 +150,7 @@ func (x *transportStreamClient) Recv() (*Message, error) {
|
||||
return m, nil
|
||||
}
|
||||
|
||||
// Server API for Transport service
|
||||
|
||||
// TransportServer is the server API for Transport service.
|
||||
type TransportServer interface {
|
||||
Stream(Transport_StreamServer) error
|
||||
}
|
||||
@ -161,28 +197,5 @@ var _Transport_serviceDesc = grpc.ServiceDesc{
|
||||
ClientStreams: true,
|
||||
},
|
||||
},
|
||||
Metadata: "github.com/micro/go-plugins/transport/grpc/proto/transport.proto",
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("github.com/micro/go-plugins/transport/grpc/proto/transport.proto", fileDescriptor0)
|
||||
}
|
||||
|
||||
var fileDescriptor0 = []byte{
|
||||
// 234 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x72, 0x48, 0xcf, 0x2c, 0xc9,
|
||||
0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xcf, 0xcd, 0x4c, 0x2e, 0xca, 0xd7, 0x4f, 0xcf, 0xd7,
|
||||
0x2d, 0xc8, 0x29, 0x4d, 0xcf, 0xcc, 0x2b, 0xd6, 0x2f, 0x29, 0x4a, 0xcc, 0x2b, 0x2e, 0xc8, 0x2f,
|
||||
0x2a, 0xd1, 0x4f, 0x2f, 0x2a, 0x48, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x47, 0x08, 0xea, 0x81,
|
||||
0xf9, 0x42, 0xe2, 0xe9, 0xf9, 0x7a, 0x60, 0x9d, 0x7a, 0x20, 0x45, 0x7a, 0x70, 0x69, 0xa5, 0x79,
|
||||
0x8c, 0x5c, 0xec, 0xbe, 0xa9, 0xc5, 0xc5, 0x89, 0xe9, 0xa9, 0x42, 0x2e, 0x5c, 0x6c, 0x19, 0xa9,
|
||||
0x89, 0x29, 0xa9, 0x45, 0x12, 0x8c, 0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0x3a, 0x7a, 0x38, 0x74, 0xe9,
|
||||
0x41, 0x75, 0xe8, 0x79, 0x80, 0x95, 0xbb, 0xe6, 0x95, 0x14, 0x55, 0x06, 0x41, 0xf5, 0x0a, 0x09,
|
||||
0x71, 0xb1, 0x24, 0xe5, 0xa7, 0x54, 0x4a, 0x30, 0x29, 0x30, 0x6a, 0xf0, 0x04, 0x81, 0xd9, 0x52,
|
||||
0x96, 0x5c, 0xdc, 0x48, 0x4a, 0x85, 0x04, 0xb8, 0x98, 0xb3, 0x53, 0x2b, 0x25, 0x18, 0x15, 0x18,
|
||||
0x35, 0x38, 0x83, 0x40, 0x4c, 0x21, 0x11, 0x2e, 0xd6, 0xb2, 0xc4, 0x9c, 0xd2, 0x54, 0xb0, 0x2e,
|
||||
0xce, 0x20, 0x08, 0xc7, 0x8a, 0xc9, 0x82, 0xd1, 0x28, 0x9e, 0x8b, 0x33, 0x04, 0x66, 0xaf, 0x50,
|
||||
0x10, 0x17, 0x5b, 0x70, 0x49, 0x51, 0x6a, 0x62, 0xae, 0x90, 0x02, 0x21, 0xb7, 0x49, 0x11, 0x54,
|
||||
0xa1, 0xc4, 0xa0, 0xc1, 0x68, 0xc0, 0x98, 0xc4, 0x06, 0x0e, 0x21, 0x63, 0x40, 0x00, 0x00, 0x00,
|
||||
0xff, 0xff, 0x4e, 0xcc, 0x76, 0x38, 0x65, 0x01, 0x00, 0x00,
|
||||
Metadata: "go-micro/transport/grpc/proto/transport.proto",
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package grpc
|
||||
|
||||
import (
|
||||
"github.com/micro/go-micro/transport"
|
||||
pb "github.com/micro/go-plugins/transport/grpc/proto"
|
||||
pb "github.com/micro/go-micro/transport/grpc/proto"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
"github.com/lucas-clemente/quic-go"
|
||||
"github.com/micro/go-micro/transport"
|
||||
utls "github.com/micro/util/go/lib/tls"
|
||||
utls "github.com/micro/go-micro/util/tls"
|
||||
)
|
||||
|
||||
type quicSocket struct {
|
||||
|
114
web/README.md
Normal file
114
web/README.md
Normal file
@ -0,0 +1,114 @@
|
||||
# Go Web [![GoDoc](https://godoc.org/github.com/micro/go-micro/web?status.svg)](https://godoc.org/github.com/micro/go-micro/web) [![Travis CI](https://travis-ci.org/micro/go-micro/web.svg?branch=master)](https://travis-ci.org/micro/go-micro/web) [![Go Report Card](https://goreportcard.com/badge/micro/go-micro/web)](https://goreportcard.com/report/github.com/micro/go-micro/web)
|
||||
|
||||
**Go Web** is a framework for micro service web development.
|
||||
|
||||
## Overview
|
||||
|
||||
Go Web provides a tiny HTTP web server library which leverages [go-micro](https://github.com/micro/go-micro) to create
|
||||
micro web services as first class citizens in a microservice world. It wraps go-micro to give you service discovery,
|
||||
heartbeating and the ability to create web apps as microservices.
|
||||
|
||||
## Features
|
||||
|
||||
- **Service Discovery** - Services are automatically registered in service discovery on startup. Go Web includes
|
||||
a http.Client with pre-initialised roundtripper which makes use of service discovery so you can use service names.
|
||||
|
||||
- **Heartbeating** - Go Web apps will periodically heartbeat with service discovery to provide liveness updates.
|
||||
In the event a service fails it will be removed from the registry after a pre-defined expiry time.
|
||||
|
||||
- **Custom Handlers** - Specify your own http router for handling requests. This allows you to maintain full
|
||||
control over how you want to route to internal handlers.
|
||||
|
||||
- **Static Serving** - Go Web automatically detects a local static `html` dir and serves files if no route handler
|
||||
is specified. A quick solution for those who want to write JS web apps as microservices.
|
||||
|
||||
## Getting Started
|
||||
|
||||
- [Dependencies](#dependencies)
|
||||
- [Usage](#usage)
|
||||
- [Set Handler](#set-handler)
|
||||
- [Call Service](#call-service)
|
||||
- [Static Files](#static-files)
|
||||
|
||||
## Dependencies
|
||||
|
||||
Go Web makes use of Go Micro which means it needs service discovery
|
||||
|
||||
See the [go-micro](https://github.com/micro/go-micro#service-discovery) for install instructions
|
||||
|
||||
For a quick start use consul
|
||||
|
||||
```
|
||||
# install
|
||||
brew install consul
|
||||
|
||||
# run
|
||||
consul agent -dev
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
service := web.NewService(
|
||||
web.Name("example.com"),
|
||||
)
|
||||
|
||||
service.HandleFunc("/foo", fooHandler)
|
||||
|
||||
if err := service.Init(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := service.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
```
|
||||
|
||||
## Set Handler
|
||||
|
||||
You might have a preference for a HTTP handler, so use something else. This loses the ability to register endpoints in discovery
|
||||
but we'll fix that soon.
|
||||
|
||||
```go
|
||||
import "github.com/gorilla/mux"
|
||||
|
||||
r := mux.NewRouter()
|
||||
r.HandleFunc("/", indexHandler)
|
||||
r.HandleFunc("/objects/{object}", objectHandler)
|
||||
|
||||
service := web.NewService(
|
||||
web.Handler(r)
|
||||
)
|
||||
```
|
||||
|
||||
## Call Service
|
||||
|
||||
Go-web includes a http.Client with a custom http.RoundTripper that uses service discovery
|
||||
|
||||
```go
|
||||
c := service.Client()
|
||||
|
||||
rsp, err := c.Get("http://example.com/foo")
|
||||
```
|
||||
|
||||
This will lookup service discovery for the service `example.com` and route to one of the available nodes.
|
||||
|
||||
## Static Files
|
||||
|
||||
Go web was always meant as a way to register web apps where the majority of the code would be written in JS. To enable that by default, if no handler is registered on "/" and we find a local "html" directory then static files will be served.
|
||||
|
||||
You will see a log output like so.
|
||||
|
||||
```
|
||||
2019/05/12 14:55:47 Enabling static file serving from /tmp/foo/html
|
||||
```
|
||||
|
||||
If you want to set this path manually use the StaticDir option. If a relative path is specified we will use os.Getwd() and prefix this.
|
||||
|
||||
```
|
||||
service := web.NewService(
|
||||
web.Name("example.com"),
|
||||
web.StaticDir("/tmp/example.com/html"),
|
||||
)
|
||||
|
||||
```
|
7
web/examples/README.md
Normal file
7
web/examples/README.md
Normal file
@ -0,0 +1,7 @@
|
||||
# Examples
|
||||
|
||||
Name | Description
|
||||
--- | ---
|
||||
[Message](https://github.com/micro/message-web) | A simple text based messaging web app
|
||||
[Geo](https://github.com/micro/geo-web) | A geo location map demo
|
||||
|
29
web/examples/helloworld/helloworld.go
Normal file
29
web/examples/helloworld/helloworld.go
Normal file
@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/micro/go-micro/web"
|
||||
)
|
||||
|
||||
func helloWorldHandler(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprint(w, `<html><body><h1>Hello World</h1></body></html>`)
|
||||
}
|
||||
|
||||
func main() {
|
||||
service := web.NewService(
|
||||
web.Name("helloworld"),
|
||||
)
|
||||
|
||||
service.HandleFunc("/", helloWorldHandler)
|
||||
|
||||
if err := service.Init(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := service.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
217
web/options.go
Normal file
217
web/options.go
Normal file
@ -0,0 +1,217 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/micro/cli"
|
||||
"github.com/micro/go-micro"
|
||||
"github.com/micro/go-micro/registry"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
Name string
|
||||
Version string
|
||||
Id string
|
||||
Metadata map[string]string
|
||||
Address string
|
||||
Advertise string
|
||||
|
||||
Action func(*cli.Context)
|
||||
Flags []cli.Flag
|
||||
|
||||
RegisterTTL time.Duration
|
||||
RegisterInterval time.Duration
|
||||
|
||||
Server *http.Server
|
||||
Handler http.Handler
|
||||
|
||||
// Alternative Options
|
||||
Context context.Context
|
||||
|
||||
Registry registry.Registry
|
||||
Service micro.Service
|
||||
|
||||
Secure bool
|
||||
TLSConfig *tls.Config
|
||||
BeforeStart []func() error
|
||||
BeforeStop []func() error
|
||||
AfterStart []func() error
|
||||
AfterStop []func() error
|
||||
|
||||
// Static directory
|
||||
StaticDir string
|
||||
}
|
||||
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{
|
||||
Name: DefaultName,
|
||||
Version: DefaultVersion,
|
||||
Id: DefaultId,
|
||||
Address: DefaultAddress,
|
||||
RegisterTTL: DefaultRegisterTTL,
|
||||
RegisterInterval: DefaultRegisterInterval,
|
||||
StaticDir: DefaultStaticDir,
|
||||
Service: micro.NewService(),
|
||||
Context: context.TODO(),
|
||||
}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Server name
|
||||
func Name(n string) Option {
|
||||
return func(o *Options) {
|
||||
o.Name = n
|
||||
}
|
||||
}
|
||||
|
||||
// Unique server id
|
||||
func Id(id string) Option {
|
||||
return func(o *Options) {
|
||||
o.Id = id
|
||||
}
|
||||
}
|
||||
|
||||
// Version of the service
|
||||
func Version(v string) Option {
|
||||
return func(o *Options) {
|
||||
o.Version = v
|
||||
}
|
||||
}
|
||||
|
||||
// Metadata associated with the service
|
||||
func Metadata(md map[string]string) Option {
|
||||
return func(o *Options) {
|
||||
o.Metadata = md
|
||||
}
|
||||
}
|
||||
|
||||
// Address to bind to - host:port
|
||||
func Address(a string) Option {
|
||||
return func(o *Options) {
|
||||
o.Address = a
|
||||
}
|
||||
}
|
||||
|
||||
// The address to advertise for discovery - host:port
|
||||
func Advertise(a string) Option {
|
||||
return func(o *Options) {
|
||||
o.Advertise = a
|
||||
}
|
||||
}
|
||||
|
||||
// Context specifies a context for the service.
|
||||
// Can be used to signal shutdown of the service.
|
||||
// Can be used for extra option values.
|
||||
func Context(ctx context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = ctx
|
||||
}
|
||||
}
|
||||
|
||||
func Registry(r registry.Registry) Option {
|
||||
return func(o *Options) {
|
||||
o.Registry = r
|
||||
}
|
||||
}
|
||||
|
||||
func RegisterTTL(t time.Duration) Option {
|
||||
return func(o *Options) {
|
||||
o.RegisterTTL = t
|
||||
}
|
||||
}
|
||||
|
||||
func RegisterInterval(t time.Duration) Option {
|
||||
return func(o *Options) {
|
||||
o.RegisterInterval = t
|
||||
}
|
||||
}
|
||||
|
||||
func Handler(h http.Handler) Option {
|
||||
return func(o *Options) {
|
||||
o.Handler = h
|
||||
}
|
||||
}
|
||||
|
||||
func Server(srv *http.Server) Option {
|
||||
return func(o *Options) {
|
||||
o.Server = srv
|
||||
}
|
||||
}
|
||||
|
||||
// MicroService sets the micro.Service used internally
|
||||
func MicroService(s micro.Service) Option {
|
||||
return func(o *Options) {
|
||||
o.Service = s
|
||||
}
|
||||
}
|
||||
|
||||
// Flags sets the command flags.
|
||||
func Flags(flags ...cli.Flag) Option {
|
||||
return func(o *Options) {
|
||||
o.Flags = append(o.Flags, flags...)
|
||||
}
|
||||
}
|
||||
|
||||
// Action sets the command action.
|
||||
func Action(a func(*cli.Context)) Option {
|
||||
return func(o *Options) {
|
||||
o.Action = a
|
||||
}
|
||||
}
|
||||
|
||||
// BeforeStart is executed before the server starts.
|
||||
func BeforeStart(fn func() error) Option {
|
||||
return func(o *Options) {
|
||||
o.BeforeStart = append(o.BeforeStart, fn)
|
||||
}
|
||||
}
|
||||
|
||||
// BeforeStop is executed before the server stops.
|
||||
func BeforeStop(fn func() error) Option {
|
||||
return func(o *Options) {
|
||||
o.BeforeStop = append(o.BeforeStop, fn)
|
||||
}
|
||||
}
|
||||
|
||||
// AfterStart is executed after server start.
|
||||
func AfterStart(fn func() error) Option {
|
||||
return func(o *Options) {
|
||||
o.AfterStart = append(o.AfterStart, fn)
|
||||
}
|
||||
}
|
||||
|
||||
// AfterStop is executed after server stop.
|
||||
func AfterStop(fn func() error) Option {
|
||||
return func(o *Options) {
|
||||
o.AfterStop = append(o.AfterStop, fn)
|
||||
}
|
||||
}
|
||||
|
||||
// Secure Use secure communication. If TLSConfig is not specified we use InsecureSkipVerify and generate a self signed cert
|
||||
func Secure(b bool) Option {
|
||||
return func(o *Options) {
|
||||
o.Secure = b
|
||||
}
|
||||
}
|
||||
|
||||
// TLSConfig to be used for the transport.
|
||||
func TLSConfig(t *tls.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.TLSConfig = t
|
||||
}
|
||||
}
|
||||
|
||||
// StaticDir sets the static file directory. This defaults to ./html
|
||||
func StaticDir(d string) Option {
|
||||
return func(o *Options) {
|
||||
o.StaticDir = d
|
||||
}
|
||||
}
|
445
web/service.go
Normal file
445
web/service.go
Normal file
@ -0,0 +1,445 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/micro/cli"
|
||||
"github.com/micro/go-micro"
|
||||
"github.com/micro/go-micro/registry"
|
||||
maddr "github.com/micro/go-micro/util/addr"
|
||||
mhttp "github.com/micro/go-micro/util/http"
|
||||
"github.com/micro/go-micro/util/log"
|
||||
mnet "github.com/micro/go-micro/util/net"
|
||||
mls "github.com/micro/go-micro/util/tls"
|
||||
)
|
||||
|
||||
type service struct {
|
||||
opts Options
|
||||
|
||||
mux *http.ServeMux
|
||||
srv *registry.Service
|
||||
|
||||
sync.Mutex
|
||||
running bool
|
||||
static bool
|
||||
exit chan chan error
|
||||
}
|
||||
|
||||
func newService(opts ...Option) Service {
|
||||
options := newOptions(opts...)
|
||||
s := &service{
|
||||
opts: options,
|
||||
mux: http.NewServeMux(),
|
||||
static: true,
|
||||
}
|
||||
s.srv = s.genSrv()
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *service) genSrv() *registry.Service {
|
||||
// default host:port
|
||||
parts := strings.Split(s.opts.Address, ":")
|
||||
host := strings.Join(parts[:len(parts)-1], ":")
|
||||
port, _ := strconv.Atoi(parts[len(parts)-1])
|
||||
|
||||
// check the advertise address first
|
||||
// if it exists then use it, otherwise
|
||||
// use the address
|
||||
if len(s.opts.Advertise) > 0 {
|
||||
parts = strings.Split(s.opts.Advertise, ":")
|
||||
|
||||
// we have host:port
|
||||
if len(parts) > 1 {
|
||||
// set the host
|
||||
host = strings.Join(parts[:len(parts)-1], ":")
|
||||
|
||||
// get the port
|
||||
if aport, _ := strconv.Atoi(parts[len(parts)-1]); aport > 0 {
|
||||
port = aport
|
||||
}
|
||||
} else {
|
||||
host = parts[0]
|
||||
}
|
||||
}
|
||||
|
||||
addr, err := maddr.Extract(host)
|
||||
if err != nil {
|
||||
// best effort localhost
|
||||
addr = "127.0.0.1"
|
||||
}
|
||||
|
||||
return ®istry.Service{
|
||||
Name: s.opts.Name,
|
||||
Version: s.opts.Version,
|
||||
Nodes: []*registry.Node{®istry.Node{
|
||||
Id: s.opts.Id,
|
||||
Address: addr,
|
||||
Port: port,
|
||||
Metadata: s.opts.Metadata,
|
||||
}},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *service) run(exit chan bool) {
|
||||
if s.opts.RegisterInterval <= time.Duration(0) {
|
||||
return
|
||||
}
|
||||
|
||||
t := time.NewTicker(s.opts.RegisterInterval)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-t.C:
|
||||
s.register()
|
||||
case <-exit:
|
||||
t.Stop()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *service) register() error {
|
||||
if s.srv == nil {
|
||||
return nil
|
||||
}
|
||||
// default to service registry
|
||||
r := s.opts.Service.Client().Options().Registry
|
||||
// switch to option if specified
|
||||
if s.opts.Registry != nil {
|
||||
r = s.opts.Registry
|
||||
}
|
||||
return r.Register(s.srv, registry.RegisterTTL(s.opts.RegisterTTL))
|
||||
}
|
||||
|
||||
func (s *service) deregister() error {
|
||||
if s.srv == nil {
|
||||
return nil
|
||||
}
|
||||
// default to service registry
|
||||
r := s.opts.Service.Client().Options().Registry
|
||||
// switch to option if specified
|
||||
if s.opts.Registry != nil {
|
||||
r = s.opts.Registry
|
||||
}
|
||||
return r.Deregister(s.srv)
|
||||
}
|
||||
|
||||
func (s *service) start() error {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
||||
if s.running {
|
||||
return nil
|
||||
}
|
||||
|
||||
l, err := s.listen("tcp", s.opts.Address)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
s.opts.Address = l.Addr().String()
|
||||
srv := s.genSrv()
|
||||
srv.Endpoints = s.srv.Endpoints
|
||||
s.srv = srv
|
||||
|
||||
var h http.Handler
|
||||
|
||||
if s.opts.Handler != nil {
|
||||
h = s.opts.Handler
|
||||
} else {
|
||||
h = s.mux
|
||||
var r sync.Once
|
||||
|
||||
// register the html dir
|
||||
r.Do(func() {
|
||||
// static dir
|
||||
static := s.opts.StaticDir
|
||||
if s.opts.StaticDir[0] != '/' {
|
||||
dir, _ := os.Getwd()
|
||||
static = filepath.Join(dir, static)
|
||||
}
|
||||
|
||||
// set static if no / handler is registered
|
||||
if s.static {
|
||||
_, err := os.Stat(static)
|
||||
if err == nil {
|
||||
log.Logf("Enabling static file serving from %s", static)
|
||||
s.mux.Handle("/", http.FileServer(http.Dir(static)))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
for _, fn := range s.opts.BeforeStart {
|
||||
if err := fn(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
var httpSrv *http.Server
|
||||
if s.opts.Server != nil {
|
||||
httpSrv = s.opts.Server
|
||||
} else {
|
||||
httpSrv = &http.Server{}
|
||||
}
|
||||
|
||||
httpSrv.Handler = h
|
||||
|
||||
go httpSrv.Serve(l)
|
||||
|
||||
for _, fn := range s.opts.AfterStart {
|
||||
if err := fn(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
s.exit = make(chan chan error, 1)
|
||||
s.running = true
|
||||
|
||||
go func() {
|
||||
ch := <-s.exit
|
||||
ch <- l.Close()
|
||||
}()
|
||||
|
||||
log.Logf("Listening on %v\n", l.Addr().String())
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) stop() error {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
|
||||
if !s.running {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, fn := range s.opts.BeforeStop {
|
||||
if err := fn(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
ch := make(chan error, 1)
|
||||
s.exit <- ch
|
||||
s.running = false
|
||||
|
||||
log.Log("Stopping")
|
||||
|
||||
for _, fn := range s.opts.AfterStop {
|
||||
if err := fn(); err != nil {
|
||||
if chErr := <-ch; chErr != nil {
|
||||
return chErr
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return <-ch
|
||||
}
|
||||
|
||||
func (s *service) Client() *http.Client {
|
||||
rt := mhttp.NewRoundTripper(
|
||||
mhttp.WithRegistry(registry.DefaultRegistry),
|
||||
)
|
||||
return &http.Client{
|
||||
Transport: rt,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *service) Handle(pattern string, handler http.Handler) {
|
||||
var seen bool
|
||||
for _, ep := range s.srv.Endpoints {
|
||||
if ep.Name == pattern {
|
||||
seen = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// if its unseen then add an endpoint
|
||||
if !seen {
|
||||
s.srv.Endpoints = append(s.srv.Endpoints, ®istry.Endpoint{
|
||||
Name: pattern,
|
||||
})
|
||||
}
|
||||
|
||||
// disable static serving
|
||||
if pattern == "/" {
|
||||
s.Lock()
|
||||
s.static = false
|
||||
s.Unlock()
|
||||
}
|
||||
|
||||
// register the handler
|
||||
s.mux.Handle(pattern, handler)
|
||||
}
|
||||
|
||||
func (s *service) HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request)) {
|
||||
var seen bool
|
||||
for _, ep := range s.srv.Endpoints {
|
||||
if ep.Name == pattern {
|
||||
seen = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !seen {
|
||||
s.srv.Endpoints = append(s.srv.Endpoints, ®istry.Endpoint{
|
||||
Name: pattern,
|
||||
})
|
||||
}
|
||||
|
||||
s.mux.HandleFunc(pattern, handler)
|
||||
}
|
||||
|
||||
func (s *service) Init(opts ...Option) error {
|
||||
for _, o := range opts {
|
||||
o(&s.opts)
|
||||
}
|
||||
|
||||
serviceOpts := []micro.Option{}
|
||||
|
||||
if len(s.opts.Flags) > 0 {
|
||||
serviceOpts = append(serviceOpts, micro.Flags(s.opts.Flags...))
|
||||
}
|
||||
|
||||
if s.opts.Registry != nil {
|
||||
serviceOpts = append(serviceOpts, micro.Registry(s.opts.Registry))
|
||||
}
|
||||
|
||||
serviceOpts = append(serviceOpts, micro.Action(func(ctx *cli.Context) {
|
||||
if ttl := ctx.Int("register_ttl"); ttl > 0 {
|
||||
s.opts.RegisterTTL = time.Duration(ttl) * time.Second
|
||||
}
|
||||
|
||||
if interval := ctx.Int("register_interval"); interval > 0 {
|
||||
s.opts.RegisterInterval = time.Duration(interval) * time.Second
|
||||
}
|
||||
|
||||
if name := ctx.String("server_name"); len(name) > 0 {
|
||||
s.opts.Name = name
|
||||
}
|
||||
|
||||
if ver := ctx.String("server_version"); len(ver) > 0 {
|
||||
s.opts.Version = ver
|
||||
}
|
||||
|
||||
if id := ctx.String("server_id"); len(id) > 0 {
|
||||
s.opts.Id = id
|
||||
}
|
||||
|
||||
if addr := ctx.String("server_address"); len(addr) > 0 {
|
||||
s.opts.Address = addr
|
||||
}
|
||||
|
||||
if adv := ctx.String("server_advertise"); len(adv) > 0 {
|
||||
s.opts.Advertise = adv
|
||||
}
|
||||
|
||||
if s.opts.Action != nil {
|
||||
s.opts.Action(ctx)
|
||||
}
|
||||
}))
|
||||
|
||||
s.opts.Service.Init(serviceOpts...)
|
||||
srv := s.genSrv()
|
||||
srv.Endpoints = s.srv.Endpoints
|
||||
s.srv = srv
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *service) Run() error {
|
||||
if err := s.start(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := s.register(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// start reg loop
|
||||
ex := make(chan bool)
|
||||
go s.run(ex)
|
||||
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL)
|
||||
|
||||
select {
|
||||
// wait on kill signal
|
||||
case sig := <-ch:
|
||||
log.Logf("Received signal %s\n", sig)
|
||||
// wait on context cancel
|
||||
case <-s.opts.Context.Done():
|
||||
log.Logf("Received context shutdown")
|
||||
}
|
||||
|
||||
// exit reg loop
|
||||
close(ex)
|
||||
|
||||
if err := s.deregister(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return s.stop()
|
||||
}
|
||||
|
||||
// Options returns the options for the given service
|
||||
func (s *service) Options() Options {
|
||||
return s.opts
|
||||
}
|
||||
|
||||
func (s *service) listen(network, addr string) (net.Listener, error) {
|
||||
var l net.Listener
|
||||
var err error
|
||||
|
||||
// TODO: support use of listen options
|
||||
if s.opts.Secure || s.opts.TLSConfig != nil {
|
||||
config := s.opts.TLSConfig
|
||||
|
||||
fn := func(addr string) (net.Listener, error) {
|
||||
if config == nil {
|
||||
hosts := []string{addr}
|
||||
|
||||
// check if its a valid host:port
|
||||
if host, _, err := net.SplitHostPort(addr); err == nil {
|
||||
if len(host) == 0 {
|
||||
hosts = maddr.IPs()
|
||||
} else {
|
||||
hosts = []string{host}
|
||||
}
|
||||
}
|
||||
|
||||
// generate a certificate
|
||||
cert, err := mls.Certificate(hosts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
config = &tls.Config{Certificates: []tls.Certificate{cert}}
|
||||
}
|
||||
return tls.Listen(network, addr, config)
|
||||
}
|
||||
|
||||
l, err = mnet.Listen(addr, fn)
|
||||
} else {
|
||||
fn := func(addr string) (net.Listener, error) {
|
||||
return net.Listen(network, addr)
|
||||
}
|
||||
|
||||
l, err = mnet.Listen(addr, fn)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return l, nil
|
||||
}
|
260
web/service_test.go
Normal file
260
web/service_test.go
Normal file
@ -0,0 +1,260 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/micro/go-micro/registry"
|
||||
"github.com/micro/go-micro/registry/memory"
|
||||
)
|
||||
|
||||
func TestService(t *testing.T) {
|
||||
var (
|
||||
beforeStartCalled bool
|
||||
afterStartCalled bool
|
||||
beforeStopCalled bool
|
||||
afterStopCalled bool
|
||||
str = `<html><body><h1>Hello World</h1></body></html>`
|
||||
fn = func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, str) }
|
||||
reg = memory.NewRegistry()
|
||||
)
|
||||
|
||||
beforeStart := func() error {
|
||||
beforeStartCalled = true
|
||||
return nil
|
||||
}
|
||||
|
||||
afterStart := func() error {
|
||||
afterStartCalled = true
|
||||
return nil
|
||||
}
|
||||
|
||||
beforeStop := func() error {
|
||||
beforeStopCalled = true
|
||||
return nil
|
||||
}
|
||||
|
||||
afterStop := func() error {
|
||||
afterStopCalled = true
|
||||
return nil
|
||||
}
|
||||
|
||||
service := NewService(
|
||||
Name("go.micro.web.test"),
|
||||
Registry(reg),
|
||||
BeforeStart(beforeStart),
|
||||
AfterStart(afterStart),
|
||||
BeforeStop(beforeStop),
|
||||
AfterStop(afterStop),
|
||||
)
|
||||
|
||||
service.HandleFunc("/", fn)
|
||||
|
||||
go func() {
|
||||
if err := service.Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
||||
var s []*registry.Service
|
||||
|
||||
eventually(func() bool {
|
||||
var err error
|
||||
s, err = reg.GetService("go.micro.web.test")
|
||||
return err == nil
|
||||
}, t.Fatal)
|
||||
|
||||
if have, want := len(s), 1; have != want {
|
||||
t.Fatalf("Expected %d but got %d services", want, have)
|
||||
}
|
||||
|
||||
rsp, err := http.Get(fmt.Sprintf("http://%s:%d", s[0].Nodes[0].Address, s[0].Nodes[0].Port))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer rsp.Body.Close()
|
||||
|
||||
b, err := ioutil.ReadAll(rsp.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if string(b) != str {
|
||||
t.Errorf("Expected %s got %s", str, string(b))
|
||||
}
|
||||
|
||||
callbackTests := []struct {
|
||||
subject string
|
||||
have interface{}
|
||||
}{
|
||||
{"beforeStartCalled", beforeStartCalled},
|
||||
{"afterStartCalled", afterStartCalled},
|
||||
}
|
||||
|
||||
for _, tt := range callbackTests {
|
||||
if tt.have != true {
|
||||
t.Errorf("unexpected %s: want true, have false", tt.subject)
|
||||
}
|
||||
}
|
||||
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGTERM)
|
||||
|
||||
syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
|
||||
<-ch
|
||||
|
||||
eventually(func() bool {
|
||||
_, err := reg.GetService("go.micro.web.test")
|
||||
return err == registry.ErrNotFound
|
||||
}, t.Error)
|
||||
|
||||
callbackTests = []struct {
|
||||
subject string
|
||||
have interface{}
|
||||
}{
|
||||
{"beforeStopCalled", beforeStopCalled},
|
||||
{"afterStopCalled", afterStopCalled},
|
||||
}
|
||||
|
||||
for _, tt := range callbackTests {
|
||||
if tt.have != true {
|
||||
t.Errorf("unexpected %s: want true, have false", tt.subject)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOptions(t *testing.T) {
|
||||
var (
|
||||
name = "service-name"
|
||||
id = "service-id"
|
||||
version = "service-version"
|
||||
address = "service-addr"
|
||||
advertise = "service-adv"
|
||||
reg = memory.NewRegistry()
|
||||
registerTTL = 123 * time.Second
|
||||
registerInterval = 456 * time.Second
|
||||
handler = http.NewServeMux()
|
||||
metadata = map[string]string{"key": "val"}
|
||||
secure = true
|
||||
)
|
||||
|
||||
service := NewService(
|
||||
Name(name),
|
||||
Id(id),
|
||||
Version(version),
|
||||
Address(address),
|
||||
Advertise(advertise),
|
||||
Registry(reg),
|
||||
RegisterTTL(registerTTL),
|
||||
RegisterInterval(registerInterval),
|
||||
Handler(handler),
|
||||
Metadata(metadata),
|
||||
Secure(secure),
|
||||
)
|
||||
|
||||
opts := service.Options()
|
||||
|
||||
tests := []struct {
|
||||
subject string
|
||||
want interface{}
|
||||
have interface{}
|
||||
}{
|
||||
{"name", name, opts.Name},
|
||||
{"version", version, opts.Version},
|
||||
{"id", id, opts.Id},
|
||||
{"address", address, opts.Address},
|
||||
{"advertise", advertise, opts.Advertise},
|
||||
{"registry", reg, opts.Registry},
|
||||
{"registerTTL", registerTTL, opts.RegisterTTL},
|
||||
{"registerInterval", registerInterval, opts.RegisterInterval},
|
||||
{"handler", handler, opts.Handler},
|
||||
{"metadata", metadata["key"], opts.Metadata["key"]},
|
||||
{"secure", secure, opts.Secure},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
if tc.want != tc.have {
|
||||
t.Errorf("unexpected %s: want %v, have %v", tc.subject, tc.want, tc.have)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func eventually(pass func() bool, fail func(...interface{})) {
|
||||
tick := time.NewTicker(10 * time.Millisecond)
|
||||
defer tick.Stop()
|
||||
|
||||
timeout := time.After(time.Second)
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-timeout:
|
||||
fail("timed out")
|
||||
return
|
||||
case <-tick.C:
|
||||
if pass() {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestTLS(t *testing.T) {
|
||||
var (
|
||||
str = `<html><body><h1>Hello World</h1></body></html>`
|
||||
fn = func(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, str) }
|
||||
secure = true
|
||||
reg = memory.NewRegistry()
|
||||
)
|
||||
|
||||
service := NewService(
|
||||
Name("go.micro.web.test"),
|
||||
Secure(secure),
|
||||
Registry(reg),
|
||||
)
|
||||
|
||||
service.HandleFunc("/", fn)
|
||||
|
||||
go func() {
|
||||
if err := service.Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
||||
var s []*registry.Service
|
||||
|
||||
eventually(func() bool {
|
||||
var err error
|
||||
s, err = reg.GetService("go.micro.web.test")
|
||||
return err == nil
|
||||
}, t.Fatal)
|
||||
|
||||
if have, want := len(s), 1; have != want {
|
||||
t.Fatalf("Expected %d but got %d services", want, have)
|
||||
}
|
||||
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
client := &http.Client{Transport: tr}
|
||||
rsp, err := client.Get(fmt.Sprintf("https://%s:%d", s[0].Nodes[0].Address, s[0].Nodes[0].Port))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer rsp.Body.Close()
|
||||
|
||||
b, err := ioutil.ReadAll(rsp.Body)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if string(b) != str {
|
||||
t.Errorf("Expected %s got %s", str, string(b))
|
||||
}
|
||||
}
|
41
web/web.go
Normal file
41
web/web.go
Normal file
@ -0,0 +1,41 @@
|
||||
// Package web provides web based micro services
|
||||
package web
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Service is a web service with service discovery built in
|
||||
type Service interface {
|
||||
Client() *http.Client
|
||||
Init(opts ...Option) error
|
||||
Options() Options
|
||||
Handle(pattern string, handler http.Handler)
|
||||
HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
|
||||
Run() error
|
||||
}
|
||||
|
||||
type Option func(o *Options)
|
||||
|
||||
var (
|
||||
// For serving
|
||||
DefaultName = "go-web"
|
||||
DefaultVersion = "latest"
|
||||
DefaultId = uuid.New().String()
|
||||
DefaultAddress = ":0"
|
||||
|
||||
// for registration
|
||||
DefaultRegisterTTL = time.Minute
|
||||
DefaultRegisterInterval = time.Second * 30
|
||||
|
||||
// static directory
|
||||
DefaultStaticDir = "html"
|
||||
)
|
||||
|
||||
// NewService returns a new web.Service
|
||||
func NewService(opts ...Option) Service {
|
||||
return newService(opts...)
|
||||
}
|
Loading…
Reference in New Issue
Block a user