diff --git a/docs/content/getting-started.md b/docs/content/getting-started.md index d6dfffdf6..9f9a7c009 100644 --- a/docs/content/getting-started.md +++ b/docs/content/getting-started.md @@ -17,6 +17,49 @@ TBD TBD +## Runtime + +Included with the ocis binary is embedded a go-micro runtime that is in charge of starting services as a fork of the master process. This provides complete control over the services. Ocis extensions can be added as part of this runtime. + +```console +./bin/ocis micro +``` + +This will currently boot: + +```console +go.micro +go.micro.api +go.micro.bot +go.micro.broker +go.micro.debug +go.micro.http.broker +go.micro.monitor +go.micro.network +go.micro.proxy +go.micro.registry +go.micro.router +go.micro.runtime +go.micro.store +go.micro.tunnel +go.micro.web +``` + +Further ocis extensions can be added to the runtime via the ocis command like: + +```console +./bin/ocis hello +``` + +Which whill register: + +```console +go.micro.web.hello +go.micro.api.hello +``` + +To the list of available services. + ## Configuration We provide overall three different variants of configuration. The variant based on environment variables and commandline flags are split up into global values and command-specific values. diff --git a/go.mod b/go.mod index 76ede4499..0e8413a04 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,8 @@ require ( contrib.go.opencensus.io/exporter/zipkin v0.1.1 github.com/gorilla/mux v1.7.3 github.com/micro/cli v0.2.0 - github.com/micro/go-micro v1.17.1 + github.com/micro/go-micro v1.18.0 + github.com/micro/micro v1.18.0 github.com/oklog/run v1.0.0 github.com/openzipkin/zipkin-go v0.2.2 github.com/owncloud/ocis-graph v0.0.0-20191211134602-307fdc810c1c @@ -21,4 +22,6 @@ require ( github.com/rs/zerolog v1.17.2 github.com/spf13/viper v1.6.1 go.opencensus.io v0.22.2 + google.golang.org/appengine v1.6.1 + gopkg.in/urfave/cli.v1 v1.20.0 // indirect ) diff --git a/go.sum b/go.sum index faaebbd53..2df838395 100644 --- a/go.sum +++ b/go.sum @@ -113,8 +113,11 @@ github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b/go.mod h1:H0wQ github.com/bradfitz/iter v0.0.0-20140124041915-454541ec3da2/go.mod h1:PyRFw1Lt2wKX4ZVSQ2mk+PeDa1rxyObEDlApuIsUKuo= github.com/bradfitz/iter v0.0.0-20190303215204-33e6a9893b0c/go.mod h1:PyRFw1Lt2wKX4ZVSQ2mk+PeDa1rxyObEDlApuIsUKuo= github.com/bwmarrin/discordgo v0.19.0/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q= +github.com/bwmarrin/discordgo v0.20.1 h1:Ihh3/mVoRwy3otmaoPDUioILBJq4fdWkpsi83oj2Lmk= github.com/bwmarrin/discordgo v0.20.1/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q= +github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= +github.com/cenkalti/backoff/v3 v3.0.0 h1:ske+9nBpD9qZsTBoF41nW5L+AIuFBKMeze18XQ3eG1c= github.com/cenkalti/backoff/v3 v3.0.0/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1 h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk= @@ -127,11 +130,17 @@ github.com/cespare/xxhash/v2 v2.1.0 h1:yTUvW7Vhb89inJ+8irsUqiWjh8iT6sQPZiQzI6ReG github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM= github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE= github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cloudflare-go v0.10.2/go.mod h1:qhVI5MKwBGhdNU89ZRz2plgYutcJ5PCekLxXn56w6SY= +github.com/cloudflare/cloudflare-go v0.10.6 h1:mbv0IrcrrLlPLxAzCdW6aQ/CPlqhyXrXTjviU0Tb+34= github.com/cloudflare/cloudflare-go v0.10.6/go.mod h1:dcRl7AXBH5Bf7QFTBVc3TRzwvotSeO4AlnMhuxORAX8= +github.com/cloudflare/cloudflare-go v0.10.8 h1:waPdLF0S9hb9Q8unE3A/zFJDMaPI1xZNYu/WL0aw8rE= +github.com/cloudflare/cloudflare-go v0.10.8/go.mod h1:+LCrBrz3ssRmKHnlTwQOUmi3tMcNi0H5UqpMUgKkwcg= github.com/containerd/cgroups v0.0.0-20190919134610-bf292b21730f/go.mod h1:OApqhQ4XNSNC13gXIwDjhOQxjWa/NxkwZXJ1EvqT0ko= github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw= github.com/containerd/containerd v1.3.0-beta.2.0.20190828155532-0293cbd26c69/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= @@ -180,6 +189,7 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts= +github.com/eknkc/basex v1.0.0 h1:R2zGRGJAcqEES03GqHU9leUF5n4Pg6ahazPbSTQWCWc= github.com/eknkc/basex v1.0.0/go.mod h1:k/F/exNEHFdbs3ZHuasoP2E7zeWwZblG84Y7Z59vQRo= github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= @@ -192,6 +202,7 @@ github.com/exoscale/egoscale v0.18.1/go.mod h1:Z7OOdzzTOz1Q1PjQXumlz9Wn/CddH0zSY github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= +github.com/forestgiant/sliceutil v0.0.0-20160425183142-94783f95db6c h1:pBgVXWDXju1m8W4lnEeIqTHPOzhTUO81a7yknM/xQR4= github.com/forestgiant/sliceutil v0.0.0-20160425183142-94783f95db6c/go.mod h1:pFdJbAhRf7rh6YYMUdIQGyzne6zYL1tCUW8QV2B3UfY= github.com/fortytw2/leaktest v1.2.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= @@ -209,6 +220,8 @@ github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod github.com/glycerine/goconvey v0.0.0-20180728074245-46e3a41ad493/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/go-acme/lego/v3 v3.1.0 h1:yanYFoYW8azFkCvJfIk7edWWfjkYkhDxe45ZsxoW4Xk= github.com/go-acme/lego/v3 v3.1.0/go.mod h1:074uqt+JS6plx+c9Xaiz6+L+GBb+7itGtzfcDM2AhEE= +github.com/go-acme/lego/v3 v3.2.0 h1:z0zvNlL1niv/1qA06V5X1BRC5PeLoGKAlVaWthXQz9c= +github.com/go-acme/lego/v3 v3.2.0/go.mod h1:074uqt+JS6plx+c9Xaiz6+L+GBb+7itGtzfcDM2AhEE= github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs= github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-chi/render v1.0.1 h1:4/5tis2cKaNdnv9zFLfXzcquC9HbeZgCnxGnKrltBS8= @@ -304,6 +317,7 @@ github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.2.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.1.0/go.mod h1:f5nM7jw/oeRSadq3xCzHAvxcr8HZnzsqU6ILg/0NiiE= @@ -314,6 +328,7 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.2/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.4 h1:5xLhQjsk4zqPf9EHCrja2qFZMx+yBqkO3XgJ14bNnU0= github.com/grpc-ecosystem/grpc-gateway v1.9.4/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= +github.com/hako/branca v0.0.0-20180808000428-10b799466ada h1:RjbRG4Xq2N5UaUUL9/v+yGBhgLgQwlHk582Pr0j0g00= github.com/hako/branca v0.0.0-20180808000428-10b799466ada/go.mod h1:tOPn4gvKEUWqIJNE+zpTeTALaRAXnrRqqSnPlO3VpEo= github.com/hashicorp/consul/api v1.2.0/go.mod h1:1SIkFYi2ZTXUE5Kgt179+4hH33djo11+0Eo2XgTAtkw= github.com/hashicorp/consul/sdk v0.2.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= @@ -368,6 +383,7 @@ github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/joncalhoun/qson v0.0.0-20170526102502-8a9cab3a62b1 h1:lnrOS18wZBYrzdDmnUeg1OVk+kQ3rxG8mZWU89DpMIA= github.com/joncalhoun/qson v0.0.0-20170526102502-8a9cab3a62b1/go.mod h1:DFXrEwSRX0p/aSvxE21319menCBFeQO0jXpRj7LEZUA= github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -390,6 +406,7 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/cpuid v1.2.0 h1:NMpwD2G9JSFOE1/TJjGSo5zG7Yb2bTe7eq1jH+irmeE= github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/kolo/xmlrpc v0.0.0-20190717152603-07c4ee3fd181/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -431,22 +448,29 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-tty v0.0.0-20180219170247-931426f7535a/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mholt/certmagic v0.7.5/go.mod h1:91uJzK5K8IWtYQqTi5R2tsxV1pCde+wdGfaRaOZi6aQ= +github.com/mholt/certmagic v0.8.3 h1:JOUiX9IAZbbgyjNP2GY6v/6lorH+9GkZsc7ktMpGCSo= github.com/mholt/certmagic v0.8.3/go.mod h1:91uJzK5K8IWtYQqTi5R2tsxV1pCde+wdGfaRaOZi6aQ= github.com/micro/cli v0.2.0 h1:ut3rV5JWqZjsXIa2MvGF+qMUP8DAUTvHX9Br5gO4afA= github.com/micro/cli v0.2.0/go.mod h1:jRT9gmfVKWSS6pkKcXQ8YhUyj6bzwxK8Fp5b0Y7qNnk= github.com/micro/go-micro v1.16.0/go.mod h1:A0F58bHLh2m0LAI9QyhvmbN8c1cxhAZo3cM6s+iDsrM= github.com/micro/go-micro v1.17.1 h1:BhwC4Lnwr3hdci9T8kN5MEabKS+CT0QT0YH4hinTdNs= github.com/micro/go-micro v1.17.1/go.mod h1:klwUJL1gkdY1MHFyz+fFJXn52dKcty4hoe95Mp571AA= +github.com/micro/go-micro v1.18.0 h1:gP70EZVHpJuUIT0YWth192JmlIci+qMOEByHm83XE9E= +github.com/micro/go-micro v1.18.0/go.mod h1:klwUJL1gkdY1MHFyz+fFJXn52dKcty4hoe95Mp571AA= github.com/micro/go-plugins v1.5.1 h1:swcFD7ynCTUo98APqIEIbPu2XMd6yVGTnI8PqdnCwOQ= github.com/micro/go-plugins v1.5.1/go.mod h1:jcxejzJCAMH731cQHbS/hncyKe0rxAbzKkibj8glad4= github.com/micro/mdns v0.3.0 h1:bYycYe+98AXR3s8Nq5qvt6C573uFTDPIYzJemWON0QE= github.com/micro/mdns v0.3.0/go.mod h1:KJ0dW7KmicXU2BV++qkLlmHYcVv7/hHnbtguSWt9Aoc= +github.com/micro/micro v1.16.0 h1:qCZV20WoTOtJ1IyLU/a0A0BMSertfu+iOj/2AJ4Uvrk= github.com/micro/micro v1.16.0/go.mod h1:TO5Ng0KidbfRYIxVM4Q3deZ0A+qwRyP9WeXp+k2fWNA= +github.com/micro/micro v1.18.0 h1:v+xiQOXbT9xxotLwu1nJM81t4FbruBxZSSyIdhUfujM= +github.com/micro/micro v1.18.0/go.mod h1:F7X6NCpW9Jh5w/qQJhh9/aLfcY+oMO/oWeLg3yrURbI= github.com/micro/protoc-gen-micro v1.0.0/go.mod h1:C8ij4DJhapBmypcT00AXdb0cZ675/3PqUO02buWWqbE= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/miekg/dns v1.1.3/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= @@ -497,6 +521,7 @@ github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/nats-io/stan.go v0.5.0/go.mod h1:dYqB+vMN3C2F9pT1FRQpg9eHbjPj6mP0yYuyBNuXHZE= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= +github.com/nlopes/slack v0.6.0 h1:jt0jxVQGhssx1Ib7naAOZEZcGdtIhTzkP0nopK0AsRA= github.com/nlopes/slack v0.6.0/go.mod h1:JzQ9m3PMAqcpeCam7UaHSuBuupz7CmpjehYMayT6YOk= github.com/nrdcg/auroradns v1.0.0/go.mod h1:6JPXKzIRzZzMqtTDgueIhTi6rFf1QvYE/HzqidhOhjw= github.com/nrdcg/goinwx v0.6.1/go.mod h1:XPiut7enlbEdntAqalBIqcYcTEVhpv/dKWgDCX2SwKQ= @@ -508,7 +533,10 @@ github.com/ogier/pflag v0.0.1/go.mod h1:zkFki7tvTa0tafRvTBIZTvzYyAu6kQhPZFnshFFP github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= 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.1 h1:b3iUnf1v+ppJiOfNX4yxxqfWKMQPZR5yoh8urCTFX88= github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.2 h1:sq53g+DWf0J6/ceFUHpQ0nAEb6WgM++fq16MZ91cS6o= +github.com/olekukonko/tablewriter v0.0.2/go.mod h1:rSAaSIOAGT9odnlyGlUfAJaoc5w2fSBUmeGDbRWPxyQ= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -562,6 +590,7 @@ github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c/go.mod h1:X07ZCGwU github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= +github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= @@ -624,6 +653,7 @@ github.com/sacloud/libsacloud v1.26.1/go.mod h1:79ZwATmHLIFZIMd7sxA3LwzVy/B77uj3 github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516 h1:ofR1ZdrNSkiWcMsRrubK9tb2/SlZVWttAfqUjJi6QYc= github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516/go.mod h1:Yow6lPLSAXx2ifx470yD/nUe22Dv5vBvxK/UK9UUTVs= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -668,6 +698,7 @@ github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203/go.mod h1:oqN97ltKN github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= +github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= github.com/timewasted/linode v0.0.0-20160829202747-37e84520dcf7/go.mod h1:imsgLplxEC/etjIhdr3dNzV3JeT27LbVu5pYWm0JCBY= github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= @@ -694,6 +725,7 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1: github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/xeipuuv/gojsonschema v1.1.0/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca h1:1CFlNzQhALwjS9mBAUkycX616GzgsuYUOCHA5+HSlXI= github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yaegashi/msgraph.go v0.0.0-20191104022859-3f9096c750b2 h1:37LbK2gAU+1oaWKC5NTz+fNOsR2LgdRj/SAFVMucgss= @@ -792,6 +824,7 @@ golang.org/x/net v0.0.0-20191011234655-491137f69257/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20191014212845-da9a3fd4c582/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191028085509-fe3aa8a45271/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191109021931-daa7c04131f5/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191112182307-2180aed22343/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191207000613-e7e4b65ae663 h1:Dd5RoEW+yQi+9DMybroBctIdyiwuNT7sJFMC27/6KxI= golang.org/x/net v0.0.0-20191207000613-e7e4b65ae663/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -852,7 +885,10 @@ golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 h1:xQwXv67TxFo9nC1GJFyab5eq/5B590r6RlnL/G8Sz7w= golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -890,6 +926,7 @@ google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsb google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1 h1:QzqyMA1tlu6CgqCDUtU9V+ZKhLFT2dkJuANu5QaxI3I= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -952,12 +989,16 @@ gopkg.in/olivere/elastic.v5 v5.0.82/go.mod h1:uhHoB4o3bvX5sorxBU29rPcmBQdV2Qfg0F gopkg.in/redis.v3 v3.6.4/go.mod h1:6XeGv/CrsUFDU9aVbUdNykN7k1zVmoeg83KC9RbQfiU= gopkg.in/resty.v1 v1.9.1/go.mod h1:vo52Hzryw9PnPHcJfPsBiFW62XhNx5OczbV9y+IMpgc= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/square/go-jose.v2 v2.3.1 h1:SK5KegNXmKmqE342YYN2qPHEnUYeoMiXXl1poUlI+o4= gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI= gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98= gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g= gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8= +gopkg.in/telegram-bot-api.v4 v4.6.4 h1:hpHWhzn4jTCsAJZZ2loNKfy2QWyPDRJVl3aTFXeMW8g= gopkg.in/telegram-bot-api.v4 v4.6.4/go.mod h1:5DpGO5dbumb40px+dXcwCpcjmeHNYLpk0bp3XRNvWDM= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/urfave/cli.v1 v1.20.0 h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0= +gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/pkg/command/graph.go b/pkg/command/graph.go index 2e930ae2f..60ad15657 100644 --- a/pkg/command/graph.go +++ b/pkg/command/graph.go @@ -1,15 +1,10 @@ package command import ( - "context" - "github.com/micro/cli" - "github.com/oklog/run" "github.com/owncloud/ocis-graph/pkg/command" svcconfig "github.com/owncloud/ocis-graph/pkg/config" "github.com/owncloud/ocis-graph/pkg/flagset" - "github.com/owncloud/ocis-graph/pkg/metrics" - "github.com/owncloud/ocis-graph/pkg/server/http" "github.com/owncloud/ocis/pkg/config" "github.com/owncloud/ocis/pkg/register" ) @@ -17,9 +12,10 @@ import ( // GraphCommand is the entrypoint for the graph command. func GraphCommand(cfg *config.Config) cli.Command { return cli.Command{ - Name: "graph", - Usage: "Start graph server", - Flags: flagset.ServerWithConfig(cfg.Graph), + Name: "graph", + Usage: "Start graph server", + Category: "Extensions", + Flags: flagset.ServerWithConfig(cfg.Graph), Action: func(c *cli.Context) error { scfg := configureGraph(cfg) @@ -31,44 +27,6 @@ func GraphCommand(cfg *config.Config) cli.Command { } } -// GraphHandler defines the direct server handler. -func GraphHandler(ctx context.Context, cancel context.CancelFunc, gr *run.Group, cfg *config.Config) error { - scfg := configureGraph(cfg) - logger := command.NewLogger(scfg) - m := metrics.New() - - { - server, err := http.Server( - http.Logger(logger), - http.Context(ctx), - http.Config(scfg), - http.Metrics(m), - ) - - if err != nil { - logger.Info(). - Err(err). - Str("transport", "http"). - Msg("Failed to initialize server") - - return err - } - - gr.Add(func() error { - return server.Run() - }, func(err error) { - logger.Info(). - Err(err). - Str("transport", "http"). - Msg("Shutting down server") - - cancel() - }) - } - - return nil -} - func configureGraph(cfg *config.Config) *svcconfig.Config { cfg.Graph.Log.Level = cfg.Log.Level cfg.Graph.Log.Pretty = cfg.Log.Pretty @@ -82,5 +40,4 @@ func configureGraph(cfg *config.Config) *svcconfig.Config { func init() { register.AddCommand(GraphCommand) - register.AddHandler(GraphHandler) } diff --git a/pkg/command/hello.go b/pkg/command/hello.go index c8d33a455..2ca32aeba 100644 --- a/pkg/command/hello.go +++ b/pkg/command/hello.go @@ -1,16 +1,10 @@ package command import ( - "context" - "github.com/micro/cli" - "github.com/oklog/run" "github.com/owncloud/ocis-hello/pkg/command" svcconfig "github.com/owncloud/ocis-hello/pkg/config" "github.com/owncloud/ocis-hello/pkg/flagset" - "github.com/owncloud/ocis-hello/pkg/metrics" - "github.com/owncloud/ocis-hello/pkg/server/grpc" - "github.com/owncloud/ocis-hello/pkg/server/http" "github.com/owncloud/ocis/pkg/config" "github.com/owncloud/ocis/pkg/register" ) @@ -18,9 +12,10 @@ import ( // HelloCommand is the entrypoint for the hello command. func HelloCommand(cfg *config.Config) cli.Command { return cli.Command{ - Name: "hello", - Usage: "Start hello server", - Flags: flagset.ServerWithConfig(cfg.Hello), + Name: "hello", + Usage: "Start hello server", + Category: "Extensions", + Flags: flagset.ServerWithConfig(cfg.Hello), Action: func(c *cli.Context) error { scfg := configureHello(cfg) @@ -32,71 +27,6 @@ func HelloCommand(cfg *config.Config) cli.Command { } } -// HelloHandler defines the direct server handler. -func HelloHandler(ctx context.Context, cancel context.CancelFunc, gr *run.Group, cfg *config.Config) error { - scfg := configureHello(cfg) - logger := command.NewLogger(scfg) - m := metrics.New() - - { - server, err := http.Server( - http.Logger(logger), - http.Context(ctx), - http.Config(scfg), - http.Metrics(m), - ) - - if err != nil { - logger.Info(). - Err(err). - Str("transport", "http"). - Msg("Failed to initialize server") - - return err - } - - gr.Add(func() error { - return server.Run() - }, func(_ error) { - logger.Info(). - Str("transport", "http"). - Msg("Shutting down server") - - cancel() - }) - } - - { - server, err := grpc.Server( - grpc.Logger(logger), - grpc.Context(ctx), - grpc.Config(scfg), - grpc.Metrics(m), - ) - - if err != nil { - logger.Info(). - Err(err). - Str("transport", "grpc"). - Msg("Failed to initialize server") - - return err - } - - gr.Add(func() error { - return server.Run() - }, func(_ error) { - logger.Info(). - Str("transport", "grpc"). - Msg("Shutting down server") - - cancel() - }) - } - - return nil -} - func configureHello(cfg *config.Config) *svcconfig.Config { cfg.Hello.Log.Level = cfg.Log.Level cfg.Hello.Log.Pretty = cfg.Log.Pretty @@ -111,5 +41,4 @@ func configureHello(cfg *config.Config) *svcconfig.Config { func init() { register.AddCommand(HelloCommand) - register.AddHandler(HelloHandler) } diff --git a/pkg/command/konnectd.go b/pkg/command/konnectd.go index e3fd4d502..459aba7a5 100644 --- a/pkg/command/konnectd.go +++ b/pkg/command/konnectd.go @@ -1,15 +1,10 @@ package command import ( - "context" - "github.com/micro/cli" - "github.com/oklog/run" "github.com/owncloud/ocis-konnectd/pkg/command" svcconfig "github.com/owncloud/ocis-konnectd/pkg/config" "github.com/owncloud/ocis-konnectd/pkg/flagset" - "github.com/owncloud/ocis-konnectd/pkg/metrics" - "github.com/owncloud/ocis-konnectd/pkg/server/http" "github.com/owncloud/ocis/pkg/config" "github.com/owncloud/ocis/pkg/register" ) @@ -17,9 +12,10 @@ import ( // KonnectdCommand is the entrypoint for the konnectd command. func KonnectdCommand(cfg *config.Config) cli.Command { return cli.Command{ - Name: "konnectd", - Usage: "Start konnectd server", - Flags: flagset.ServerWithConfig(cfg.Konnectd), + Name: "konnectd", + Usage: "Start konnectd server", + Category: "Extensions", + Flags: flagset.ServerWithConfig(cfg.Konnectd), Action: func(c *cli.Context) error { scfg := configureKonnectd(cfg) @@ -31,43 +27,6 @@ func KonnectdCommand(cfg *config.Config) cli.Command { } } -// KonnectdHandler defines the direct server handler. -func KonnectdHandler(ctx context.Context, cancel context.CancelFunc, gr *run.Group, cfg *config.Config) error { - scfg := configureKonnectd(cfg) - logger := command.NewLogger(scfg) - m := metrics.New() - - { - server, err := http.Server( - http.Logger(logger), - http.Context(ctx), - http.Config(scfg), - http.Metrics(m), - ) - - if err != nil { - logger.Info(). - Err(err). - Str("transport", "http"). - Msg("Failed to initialize server") - - return err - } - - gr.Add(func() error { - return server.Run() - }, func(_ error) { - logger.Info(). - Str("transport", "http"). - Msg("Shutting down server") - - cancel() - }) - } - - return nil -} - func configureKonnectd(cfg *config.Config) *svcconfig.Config { cfg.Konnectd.Log.Level = cfg.Log.Level cfg.Konnectd.Log.Pretty = cfg.Log.Pretty @@ -81,5 +40,4 @@ func configureKonnectd(cfg *config.Config) *svcconfig.Config { func init() { register.AddCommand(KonnectdCommand) - register.AddHandler(KonnectdHandler) } diff --git a/pkg/command/ocs.go b/pkg/command/ocs.go index 770610c48..1ee0e99d7 100644 --- a/pkg/command/ocs.go +++ b/pkg/command/ocs.go @@ -1,15 +1,10 @@ package command import ( - "context" - "github.com/micro/cli" - "github.com/oklog/run" "github.com/owncloud/ocis-ocs/pkg/command" svcconfig "github.com/owncloud/ocis-ocs/pkg/config" "github.com/owncloud/ocis-ocs/pkg/flagset" - "github.com/owncloud/ocis-ocs/pkg/metrics" - "github.com/owncloud/ocis-ocs/pkg/server/http" "github.com/owncloud/ocis/pkg/config" "github.com/owncloud/ocis/pkg/register" ) @@ -17,9 +12,10 @@ import ( // OCSCommand is the entrypoint for the ocs command. func OCSCommand(cfg *config.Config) cli.Command { return cli.Command{ - Name: "ocs", - Usage: "Start ocs server", - Flags: flagset.ServerWithConfig(cfg.OCS), + Name: "ocs", + Usage: "Start ocs server", + Category: "Extensions", + Flags: flagset.ServerWithConfig(cfg.OCS), Action: func(c *cli.Context) error { scfg := configureOCS(cfg) @@ -31,43 +27,6 @@ func OCSCommand(cfg *config.Config) cli.Command { } } -// OCSHandler defines the direct server handler. -func OCSHandler(ctx context.Context, cancel context.CancelFunc, gr *run.Group, cfg *config.Config) error { - scfg := configureOCS(cfg) - logger := command.NewLogger(scfg) - m := metrics.New() - - { - server, err := http.Server( - http.Logger(logger), - http.Context(ctx), - http.Config(scfg), - http.Metrics(m), - ) - - if err != nil { - logger.Info(). - Err(err). - Str("transport", "http"). - Msg("Failed to initialize server") - - return err - } - - gr.Add(func() error { - return server.Run() - }, func(_ error) { - logger.Info(). - Str("transport", "http"). - Msg("Shutting down server") - - cancel() - }) - } - - return nil -} - func configureOCS(cfg *config.Config) *svcconfig.Config { cfg.OCS.Log.Level = cfg.Log.Level cfg.OCS.Log.Pretty = cfg.Log.Pretty @@ -81,5 +40,4 @@ func configureOCS(cfg *config.Config) *svcconfig.Config { func init() { register.AddCommand(OCSCommand) - register.AddHandler(OCSHandler) } diff --git a/pkg/command/phoenix.go b/pkg/command/phoenix.go index 6affd112f..3f3ad276b 100644 --- a/pkg/command/phoenix.go +++ b/pkg/command/phoenix.go @@ -1,15 +1,10 @@ package command import ( - "context" - "github.com/micro/cli" - "github.com/oklog/run" "github.com/owncloud/ocis-phoenix/pkg/command" svcconfig "github.com/owncloud/ocis-phoenix/pkg/config" "github.com/owncloud/ocis-phoenix/pkg/flagset" - "github.com/owncloud/ocis-phoenix/pkg/metrics" - "github.com/owncloud/ocis-phoenix/pkg/server/http" "github.com/owncloud/ocis/pkg/config" "github.com/owncloud/ocis/pkg/register" ) @@ -17,9 +12,10 @@ import ( // PhoenixCommand is the entrypoint for the phoenix command. func PhoenixCommand(cfg *config.Config) cli.Command { return cli.Command{ - Name: "phoenix", - Usage: "Start phoenix server", - Flags: flagset.ServerWithConfig(cfg.Phoenix), + Name: "phoenix", + Usage: "Start phoenix server", + Category: "Extensions", + Flags: flagset.ServerWithConfig(cfg.Phoenix), Action: func(c *cli.Context) error { scfg := configurePhoenix(cfg) @@ -31,43 +27,6 @@ func PhoenixCommand(cfg *config.Config) cli.Command { } } -// PhoenixHandler defines the direct server handler. -func PhoenixHandler(ctx context.Context, cancel context.CancelFunc, gr *run.Group, cfg *config.Config) error { - scfg := configurePhoenix(cfg) - logger := command.NewLogger(scfg) - m := metrics.New() - - { - server, err := http.Server( - http.Logger(logger), - http.Context(ctx), - http.Config(scfg), - http.Metrics(m), - ) - - if err != nil { - logger.Info(). - Err(err). - Str("transport", "http"). - Msg("Failed to initialize server") - - return err - } - - gr.Add(func() error { - return server.Run() - }, func(_ error) { - logger.Info(). - Str("transport", "http"). - Msg("Shutting down server") - - cancel() - }) - } - - return nil -} - func configurePhoenix(cfg *config.Config) *svcconfig.Config { cfg.Phoenix.Log.Level = cfg.Log.Level cfg.Phoenix.Log.Pretty = cfg.Log.Pretty @@ -81,5 +40,4 @@ func configurePhoenix(cfg *config.Config) *svcconfig.Config { func init() { register.AddCommand(PhoenixCommand) - register.AddHandler(PhoenixHandler) } diff --git a/pkg/command/root.go b/pkg/command/root.go index 26457753b..3c9211779 100644 --- a/pkg/command/root.go +++ b/pkg/command/root.go @@ -8,6 +8,7 @@ import ( "github.com/owncloud/ocis-pkg/log" "github.com/owncloud/ocis/pkg/config" "github.com/owncloud/ocis/pkg/flagset" + "github.com/owncloud/ocis/pkg/micro/runtime" "github.com/owncloud/ocis/pkg/register" "github.com/owncloud/ocis/pkg/version" "github.com/spf13/viper" @@ -80,6 +81,8 @@ func Execute() error { }, } + // TODO(refs) fix this interface and make it play nice with cli.Command to reuse and skip + // doing runtime.AddRuntime(app) for _, fn := range register.Commands { app.Commands = append( app.Commands, @@ -87,6 +90,15 @@ func Execute() error { ) } + // add runtime commands to the binary + runtime.AddRuntime(app) + + // add the runtime.Run command to the binary + app.Commands = append( + app.Commands, + runtime.Command(app), + ) + cli.HelpFlag = &cli.BoolFlag{ Name: "help,h", Usage: "Show the help", diff --git a/pkg/command/server.go b/pkg/command/server.go index 04fbb2a3e..81ea8499c 100644 --- a/pkg/command/server.go +++ b/pkg/command/server.go @@ -1,9 +1,6 @@ package command import ( - "context" - "os" - "os/signal" "strings" "time" @@ -11,12 +8,12 @@ import ( "contrib.go.opencensus.io/exporter/ocagent" "contrib.go.opencensus.io/exporter/zipkin" "github.com/micro/cli" - "github.com/oklog/run" + "github.com/micro/go-micro/config/cmd" openzipkin "github.com/openzipkin/zipkin-go" zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" "github.com/owncloud/ocis/pkg/config" "github.com/owncloud/ocis/pkg/flagset" - "github.com/owncloud/ocis/pkg/register" + "github.com/owncloud/ocis/pkg/micro/runtime" "go.opencensus.io/stats/view" "go.opencensus.io/trace" ) @@ -24,9 +21,10 @@ import ( // Server is the entrypoint for the server command. func Server(cfg *config.Config) cli.Command { return cli.Command{ - Name: "server", - Usage: "Start fullstack server", - Flags: flagset.ServerWithConfig(cfg), + Name: "server", + Usage: "Start fullstack server", + Category: "Fullstack", + Flags: flagset.ServerWithConfig(cfg), Before: func(c *cli.Context) error { if cfg.HTTP.Root != "/" { cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/") @@ -121,36 +119,19 @@ func Server(cfg *config.Config) cli.Command { Msg("Tracing is not enabled") } - var ( - gr = run.Group{} - ctx, cancel = context.WithCancel(context.Background()) + runtime := runtime.New( + runtime.Services(append(runtime.RuntimeServices, runtime.Extensions...)), + runtime.Logger(logger), + runtime.MicroRuntime(cmd.DefaultCmd.Options().Runtime), ) - defer cancel() + // fork uses the micro runtime to fork go-micro services + runtime.Start() - // register a micro gateway - // mapi.MicroGateway(ctx, cancel, &gr, cfg) + // trap blocks until a kill signal is sent + runtime.Trap() - for _, fn := range register.Handlers { - fn(ctx, cancel, &gr, cfg) - } - - { - stop := make(chan os.Signal, 1) - - gr.Add(func() error { - signal.Notify(stop, os.Interrupt) - - <-stop - - return nil - }, func(err error) { - close(stop) - cancel() - }) - } - - return gr.Run() + return nil }, } } diff --git a/pkg/command/webdav.go b/pkg/command/webdav.go index 918c7e508..5648abb67 100644 --- a/pkg/command/webdav.go +++ b/pkg/command/webdav.go @@ -1,15 +1,10 @@ package command import ( - "context" - "github.com/micro/cli" - "github.com/oklog/run" "github.com/owncloud/ocis-webdav/pkg/command" svcconfig "github.com/owncloud/ocis-webdav/pkg/config" "github.com/owncloud/ocis-webdav/pkg/flagset" - "github.com/owncloud/ocis-webdav/pkg/metrics" - "github.com/owncloud/ocis-webdav/pkg/server/http" "github.com/owncloud/ocis/pkg/config" "github.com/owncloud/ocis/pkg/register" ) @@ -17,9 +12,10 @@ import ( // WebDAVCommand is the entrypoint for the webdav command. func WebDAVCommand(cfg *config.Config) cli.Command { return cli.Command{ - Name: "webdav", - Usage: "Start webdav server", - Flags: flagset.ServerWithConfig(cfg.WebDAV), + Name: "webdav", + Usage: "Start webdav server", + Category: "Extensions", + Flags: flagset.ServerWithConfig(cfg.WebDAV), Action: func(c *cli.Context) error { scfg := configureWebDAV(cfg) @@ -31,43 +27,6 @@ func WebDAVCommand(cfg *config.Config) cli.Command { } } -// WebDAVHandler defines the direct server handler. -func WebDAVHandler(ctx context.Context, cancel context.CancelFunc, gr *run.Group, cfg *config.Config) error { - scfg := configureWebDAV(cfg) - logger := command.NewLogger(scfg) - m := metrics.New() - - { - server, err := http.Server( - http.Logger(logger), - http.Context(ctx), - http.Config(scfg), - http.Metrics(m), - ) - - if err != nil { - logger.Info(). - Err(err). - Str("transport", "http"). - Msg("Failed to initialize server") - - return err - } - - gr.Add(func() error { - return server.Run() - }, func(_ error) { - logger.Info(). - Str("transport", "http"). - Msg("Shutting down server") - - cancel() - }) - } - - return nil -} - func configureWebDAV(cfg *config.Config) *svcconfig.Config { cfg.WebDAV.Log.Level = cfg.Log.Level cfg.WebDAV.Log.Pretty = cfg.Log.Pretty @@ -81,5 +40,4 @@ func configureWebDAV(cfg *config.Config) *svcconfig.Config { func init() { register.AddCommand(WebDAVCommand) - register.AddHandler(WebDAVHandler) } diff --git a/pkg/micro/api/api.go b/pkg/micro/api/api.go deleted file mode 100644 index 89a2d0baa..000000000 --- a/pkg/micro/api/api.go +++ /dev/null @@ -1,86 +0,0 @@ -package api - -import ( - "context" - "fmt" - "net/http" - - "github.com/gorilla/mux" - "github.com/micro/go-micro" - ahandler "github.com/micro/go-micro/api/handler" - aapi "github.com/micro/go-micro/api/handler/api" - "github.com/micro/go-micro/api/resolver" - rrmicro "github.com/micro/go-micro/api/resolver/micro" - "github.com/micro/go-micro/api/router" - regRouter "github.com/micro/go-micro/api/router/registry" - httpapi "github.com/micro/go-micro/api/server/http" - "github.com/oklog/run" - "github.com/owncloud/ocis/pkg/config" - "github.com/rs/zerolog/log" -) - -// MicroGateway implements the handler interface -func MicroGateway(ctx context.Context, cancel context.CancelFunc, gr *run.Group, cfg *config.Config) error { - // create the gateway service - // var opts []server.Option - var h http.Handler - r := mux.NewRouter() - h = r - - // return version and list of services - r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - - if r.Method == "OPTIONS" { - return - } - - response := fmt.Sprintf(`{"version": "%s"}`, "[void]") - w.Write([]byte(response)) - }) - - // strip favicon.ico - r.HandleFunc("/favicon.ico", func(w http.ResponseWriter, r *http.Request) {}) - - var srvOpts []micro.Option - srvOpts = append(srvOpts, micro.Name("com.micro.api")) - - // initialise service - service := micro.NewService(srvOpts...) - - // resolver options - ropts := []resolver.Option{ - resolver.WithNamespace("com.micro"), - resolver.WithHandler("meta"), - } - - // default resolver - rr := rrmicro.NewResolver(ropts...) - - rt := regRouter.NewRouter( - router.WithNamespace("com.micro"), - router.WithHandler(aapi.Handler), - router.WithResolver(rr), - router.WithRegistry(service.Options().Registry), - ) - ap := aapi.NewHandler( - ahandler.WithNamespace("com.micro"), - ahandler.WithRouter(rt), - ahandler.WithService(service), - ) - r.PathPrefix("/").Handler(ap) - - api := httpapi.NewServer(":8111") - api.Init() - api.Handle("/", h) - - gr.Add(func() error { - return service.Run() - }, func(err error) { - log.Err(err) - - cancel() - }) - - // add it to the run group - return nil -} diff --git a/pkg/micro/runtime/command.go b/pkg/micro/runtime/command.go new file mode 100644 index 000000000..01ae03193 --- /dev/null +++ b/pkg/micro/runtime/command.go @@ -0,0 +1,31 @@ +package runtime + +import ( + "github.com/micro/cli" + "github.com/micro/go-micro/config/cmd" + "github.com/owncloud/ocis-pkg/log" +) + +// Command adds micro runtime commands to the cli app +func Command(app *cli.App) cli.Command { + command := cli.Command{ + Name: "micro", + Description: "starts the go-micro runtime services", + Category: "Micro", + Action: func(c *cli.Context) error { + runtime := New( + Services(RuntimeServices), + Logger(log.NewLogger()), + MicroRuntime(cmd.DefaultCmd.Options().Runtime), + ) + + { + runtime.Start() + runtime.Trap() + } + + return nil + }, + } + return command +} diff --git a/pkg/micro/runtime/options.go b/pkg/micro/runtime/options.go new file mode 100644 index 000000000..8fd59499e --- /dev/null +++ b/pkg/micro/runtime/options.go @@ -0,0 +1,48 @@ +package runtime + +import ( + gorun "github.com/micro/go-micro/runtime" + "github.com/owncloud/ocis-pkg/log" +) + +// Options is a runtime option +type Options struct { + Services []string + Logger log.Logger + MicroRuntime *gorun.Runtime +} + +// Option undocummented +type Option func(o *Options) + +// newOptions initializes the available default options. +func newOptions(opts ...Option) Options { + opt := Options{} + + for _, o := range opts { + o(&opt) + } + + return opt +} + +// Services option +func Services(s []string) Option { + return func(o *Options) { + o.Services = append(o.Services, s...) + } +} + +// Logger option +func Logger(l log.Logger) Option { + return func(o *Options) { + o.Logger = l + } +} + +// MicroRuntime option +func MicroRuntime(rt *gorun.Runtime) Option { + return func(o *Options) { + o.MicroRuntime = rt + } +} diff --git a/pkg/micro/runtime/runtime.go b/pkg/micro/runtime/runtime.go new file mode 100644 index 000000000..0fc2c6a25 --- /dev/null +++ b/pkg/micro/runtime/runtime.go @@ -0,0 +1,221 @@ +package runtime + +import ( + "os" + "os/signal" + "syscall" + + "github.com/micro/cli" + gorun "github.com/micro/go-micro/runtime" + "github.com/micro/micro/api" + "github.com/micro/micro/broker" + "github.com/micro/micro/health" + "github.com/micro/micro/monitor" + "github.com/micro/micro/network" + "github.com/micro/micro/plugin/build" + "github.com/micro/micro/proxy" + "github.com/micro/micro/registry" + "github.com/micro/micro/router" + "github.com/micro/micro/runtime" + "github.com/micro/micro/server" + "github.com/micro/micro/service" + "github.com/micro/micro/store" + "github.com/micro/micro/token" + "github.com/micro/micro/tunnel" + "github.com/micro/micro/web" + "github.com/owncloud/ocis-pkg/log" +) + +// OwncloudNamespace is the base path for micro' services to use +var OwncloudNamespace = "com.owncloud." + +// RuntimeServices to start as part of the fullstack option +var RuntimeServices = []string{ + // "network", // :8085 + "runtime", // :8088 + "registry", // :8000 + "broker", // :8001 + "store", // :8002 + "tunnel", // :8083 + "router", // :8084 + "proxy", // :8081 + "api", // :8080 + "web", // :8082 + "monitor", // :???? + // "debug", // :???? + // "bot", // :???? +} + +// Extensions are ocis extension services +var Extensions = []string{ + "hello", + "phoenix", + "graph", + "ocs", + "webdav", +} + +// Runtime is a micro' runtime +type Runtime struct { + Services []string + Logger log.Logger + R *gorun.Runtime +} + +// New creates a new ocis + micro runtime +func New(opts ...Option) Runtime { + options := newOptions(opts...) + + return Runtime{ + Services: options.Services, + Logger: options.Logger, + R: options.MicroRuntime, + } +} + +// Trap waits for a sigkill to stop the runtime +func (r *Runtime) Trap() { + shutdown := make(chan os.Signal, 1) + signal.Notify(shutdown, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT) + + if err := (*r.R).Start(); err != nil { + os.Exit(1) + } + + // block until there is a value + for range shutdown { + r.Logger.Info().Msg("shutdown signal received") + close(shutdown) + } + + if err := (*r.R).Stop(); err != nil { + r.Logger.Err(err) + } + + r.Logger.Info().Msgf("Service runtime shutdown") + os.Exit(0) +} + +// Start starts preconfigured services +func (r *Runtime) Start() { + env := os.Environ() + + for _, service := range r.Services { + args := []gorun.CreateOption{ + // the binary calls itself with the micro service as a subcommand as first argument + gorun.WithCommand(os.Args[0], service), + gorun.WithEnv(env), + // and logs to STDOUT. Perhaps this can be overridden to use a log.Logger + gorun.WithOutput(os.Stdout), + } + + muService := &gorun.Service{Name: service} + if err := (*r.R).Create(muService, args...); err != nil { + r.Logger.Error().Msgf("Failed to create runtime enviroment: %v", err) + } + } +} + +// AddRuntime adds the micro subcommands to the cli app +func AddRuntime(app *cli.App) { + // load this from disk / env? + setDefaults() + + app.Commands = append(app.Commands, api.Commands()...) + app.Commands = append(app.Commands, broker.Commands()...) + app.Commands = append(app.Commands, health.Commands()...) + app.Commands = append(app.Commands, proxy.Commands()...) + app.Commands = append(app.Commands, monitor.Commands()...) + app.Commands = append(app.Commands, router.Commands()...) + app.Commands = append(app.Commands, tunnel.Commands()...) + app.Commands = append(app.Commands, network.Commands()...) + app.Commands = append(app.Commands, registry.Commands()...) + app.Commands = append(app.Commands, runtime.Commands()...) + app.Commands = append(app.Commands, server.Commands()...) + app.Commands = append(app.Commands, service.Commands()...) + app.Commands = append(app.Commands, store.Commands()...) + app.Commands = append(app.Commands, token.Commands()...) + app.Commands = append(app.Commands, build.Commands()...) + app.Commands = append(app.Commands, web.Commands()...) + // app.Commands = append(app.Commands, bot.Commands()...) + // app.Commands = append(app.Commands, new.Commands()...) + // app.Commands = append(app.Commands, debug.Commands()...) +} + +// provide a config.Config with default values? +func setDefaults() { + // api + api.Name = OwncloudNamespace + "api" + api.Namespace = OwncloudNamespace + "api" + api.HeaderPrefix = "X-Micro-Owncloud-" + // api.EnableRPC = false + // api.RPCPath + // api.Address + // api.Handler + // api.Resolver + // api.ProxyPath + // api.APIPath + + // broker + broker.Name = OwncloudNamespace + "http.broker" + // broker.Address + + // proxy + proxy.Name = OwncloudNamespace + "proxy" + // proxy.Address + // proxy.Protocol + // proxy.Endpoint + + // monitor + monitor.Name = OwncloudNamespace + "monitor" + + // router + router.Name = OwncloudNamespace + "router" + // router.Address + // router.Network + // router.Topic + + // tunnel + tunnel.Name = OwncloudNamespace + "tunnel" + // tunnel.Address + // tunnel.Token + // tunnel.Tunnel + + // network + network.Name = OwncloudNamespace + "network" + // network.Address + // network.Advertise + // network.Resolver + // network.Token + + // registry + registry.Name = OwncloudNamespace + "registry" + // registry.Address + // registry.SyncTime + // registry.Topic + + // runtime + runtime.Name = OwncloudNamespace + "runtime" + // runtime.Address + + // server + server.Name = OwncloudNamespace + "server" + // server.Address + // server.Network + // server.Router + + // store + store.Name = OwncloudNamespace + "store" + // store.Address + + // web + web.Name = OwncloudNamespace + "web" + web.Namespace = OwncloudNamespace + "web" + // web.ACMECA + // web.ACMEChallengeProvider + // web.ACMEProvider + // web.Address + // web.BasePathHeader + // web.DefaultIcon + +} diff --git a/pkg/register/command.go b/pkg/register/command.go index a2d8cd63e..c439804a6 100644 --- a/pkg/register/command.go +++ b/pkg/register/command.go @@ -1,27 +1,18 @@ package register import ( - "context" - "github.com/micro/cli" - "github.com/oklog/run" "github.com/owncloud/ocis/pkg/config" ) var ( // Commands defines the slice of commands. Commands = []Command{} - - // Handlers defines the slice of handlers. - Handlers = []Handler{} ) // Command defines the register command. type Command func(*config.Config) cli.Command -// Handler defines the register handler. -type Handler func(context.Context, context.CancelFunc, *run.Group, *config.Config) error - // AddCommand appends a command to Commands. func AddCommand(cmd Command) { Commands = append( @@ -29,11 +20,3 @@ func AddCommand(cmd Command) { cmd, ) } - -// AddHandler appends a handler to Handlers. -func AddHandler(hdl Handler) { - Handlers = append( - Handlers, - hdl, - ) -}