├── .github └── workflows │ ├── main.yaml │ ├── pr.yaml │ └── release.yaml ├── .gitignore ├── .golangci.yaml ├── LICENSE ├── Makefile ├── README.md ├── go.work ├── go.work.sum ├── scripts ├── deps │ └── polaris.sh ├── fmt.sh ├── gowork.sh ├── release.sh ├── template │ └── changelog.md ├── test.sh └── upgrade-go-micro.sh ├── v2 ├── README.md ├── agent │ ├── README.md │ └── command │ │ ├── animate │ │ ├── animate.go │ │ ├── animate_test.go │ │ ├── go.mod │ │ └── go.sum │ │ ├── geocode │ │ ├── geocode.go │ │ ├── geocode_test.go │ │ ├── go.mod │ │ └── go.sum │ │ └── whereareyou │ │ ├── go.mod │ │ ├── go.sum │ │ └── whereareyou.go ├── broker │ ├── googlepubsub │ │ ├── go.mod │ │ ├── go.sum │ │ ├── googlepubsub.go │ │ └── options.go │ ├── grpc │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grpc.go │ │ ├── grpc_test.go │ │ └── proto │ │ │ ├── broker.pb.go │ │ │ └── broker.proto │ ├── http │ │ ├── go.mod │ │ ├── go.sum │ │ ├── http.go │ │ └── http_test.go │ ├── kafka │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── kafka.go │ │ └── options.go │ ├── memory │ │ ├── go.mod │ │ ├── go.sum │ │ └── memory.go │ ├── mqtt │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── mqtt.go │ │ ├── mqtt_handler.go │ │ ├── mqtt_mock.go │ │ └── mqtt_test.go │ ├── nats │ │ ├── go.mod │ │ ├── go.sum │ │ └── nats.go │ ├── proxy │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── proxy.go │ │ ├── publication.go │ │ └── subscriber.go │ ├── rabbitmq │ │ ├── auth.go │ │ ├── channel.go │ │ ├── connection.go │ │ ├── connection_test.go │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── rabbitmq.go │ │ └── rabbitmq_test.go │ ├── redis │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── redis.go │ │ └── redis_test.go │ ├── segmentio │ │ ├── broker_test.go │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── sarama_test.go │ │ ├── segmentio.go │ │ └── segmentio_test.go │ ├── service │ │ ├── go.mod │ │ ├── go.sum │ │ └── service.go │ ├── snssqs │ │ ├── README.md │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── snssqs.go │ │ ├── snssqs_test.go │ │ └── unicode.go │ ├── sqs │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── sqs.go │ ├── stan │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── stan.go │ │ └── stan_test.go │ └── stomp │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── publication.go │ │ ├── stomp.go │ │ └── subscriber.go ├── client │ ├── http │ │ ├── README.md │ │ ├── buffer.go │ │ ├── codec.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── http.go │ │ ├── http_test.go │ │ ├── message.go │ │ ├── request.go │ │ ├── stream.go │ │ └── test │ │ │ ├── test.pb.go │ │ │ └── test.proto │ ├── mock │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── mock.go │ │ ├── mock_test.go │ │ └── options.go │ └── selector │ │ ├── label │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── label.go │ │ ├── label_test.go │ │ └── options.go │ │ ├── shard │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── shard.go │ │ └── shard_test.go │ │ └── static │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── static.go │ │ └── static_test.go ├── codec │ ├── bsonrpc │ │ ├── bsonrpc.go │ │ ├── codec.go │ │ ├── go.mod │ │ └── go.sum │ ├── json-iterator │ │ ├── go.mod │ │ ├── go.sum │ │ ├── json.go │ │ └── marshaler.go │ ├── jsonrpc2 │ │ ├── README.md │ │ ├── client.go │ │ ├── errors.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── jsonrpc2.go │ │ ├── license.go │ │ └── server.go │ ├── msgpackrpc │ │ ├── README.md │ │ ├── codec.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── rpc.go │ │ └── rpc_test.go │ └── segmentio │ │ ├── go.mod │ │ ├── go.sum │ │ ├── json.go │ │ └── marshaler.go ├── config │ ├── encoder │ │ └── cue │ │ │ ├── cue.go │ │ │ ├── cue_test.go │ │ │ ├── go.mod │ │ │ └── go.sum │ └── source │ │ ├── configmap │ │ ├── README.md │ │ ├── configmap.go │ │ ├── configmap_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── testdata │ │ │ ├── config │ │ │ ├── mongodb │ │ │ └── redis │ │ ├── util.go │ │ └── watcher.go │ │ ├── consul │ │ ├── README.md │ │ ├── consul.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── util.go │ │ └── watcher.go │ │ ├── grpc │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grpc.go │ │ ├── options.go │ │ ├── proto │ │ │ ├── grpc.pb.go │ │ │ └── grpc.proto │ │ ├── util.go │ │ └── watcher.go │ │ ├── mucp │ │ ├── go.mod │ │ ├── go.sum │ │ ├── mucp.go │ │ ├── options.go │ │ ├── proto │ │ │ ├── mucp.micro.go │ │ │ ├── mucp.pb.go │ │ │ └── mucp.proto │ │ ├── util.go │ │ └── watcher.go │ │ ├── pkger │ │ ├── README.md │ │ ├── format.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── pkger.go │ │ ├── runtimevar │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── runtimevar.go │ │ └── watcher.go │ │ ├── url │ │ ├── README.md │ │ ├── format.go │ │ ├── format_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── url.go │ │ └── watcher.go │ │ └── vault │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── testdata │ │ └── vault_init_commands │ │ ├── util.go │ │ ├── vault.go │ │ ├── vault_test.go │ │ └── watcher.go ├── logger │ ├── apex │ │ ├── apex.go │ │ ├── apex_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── options.go │ ├── logrus │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── logrus.go │ │ ├── logrus_test.go │ │ └── options.go │ ├── zap │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── zap.go │ │ └── zap_test.go │ └── zerolog │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── zerolog.go │ │ └── zerolog_test.go ├── micro │ ├── README.md │ ├── allow │ │ ├── README.md │ │ ├── allow.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── wrapper.go │ ├── auth │ │ ├── auth.go │ │ ├── basic │ │ │ └── basic.go │ │ ├── digest │ │ │ └── digest.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── ldap │ │ │ └── ldap.go │ ├── cors │ │ ├── README.md │ │ ├── cors.go │ │ ├── go.mod │ │ └── go.sum │ ├── disable_rpc │ │ ├── README.md │ │ ├── disable_rpc.go │ │ ├── go.mod │ │ └── go.sum │ ├── gzip │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── gzip.go │ ├── header │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── header.go │ ├── index │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── index.go │ ├── ip_allow │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── ip_allow.go │ ├── metadata │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── metadata.go │ │ └── wrapper.go │ ├── metrics │ │ ├── go.mod │ │ ├── go.sum │ │ ├── metrics.go │ │ └── prometheus │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── prometheus.go │ ├── router │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── router.go │ │ ├── router_test.go │ │ ├── routes.go │ │ ├── routes_test.go │ │ ├── sort.go │ │ └── sort_test.go │ ├── stats_auth │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── stats_auth.go │ └── trace │ │ ├── awsxray │ │ ├── README.md │ │ ├── awsxray.go │ │ ├── awsxray.png │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── util.go │ │ ├── writer.go │ │ └── writer_test.go │ │ └── uuid │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── uuid.go ├── proxy │ └── http │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── http.go │ │ ├── http_test.go │ │ └── options.go ├── registry │ ├── cache │ │ ├── README.md │ │ ├── cache.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── options.go │ ├── consul │ │ ├── consul.go │ │ ├── encoding.go │ │ ├── encoding_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── registry_test.go │ │ ├── watcher.go │ │ └── watcher_test.go │ ├── etcd │ │ ├── etcd.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── options.go │ ├── etcdv3 │ │ ├── etcd.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── options.go │ ├── eureka │ │ ├── eureka.go │ │ ├── eureka_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── marshalling.go │ │ ├── marshalling_test.go │ │ ├── mock │ │ │ └── fargo_conn.go │ │ ├── options.go │ │ ├── options_test.go │ │ └── watcher.go │ ├── gossip │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── gossip.go │ │ ├── gossip_test.go │ │ ├── options.go │ │ ├── proto │ │ │ ├── gossip.micro.go │ │ │ ├── gossip.pb.go │ │ │ └── gossip.proto │ │ └── watcher.go │ ├── kubernetes │ │ ├── README.md │ │ ├── client │ │ │ ├── api │ │ │ │ ├── api_test.go │ │ │ │ ├── request.go │ │ │ │ └── response.go │ │ │ ├── client.go │ │ │ ├── kubernetes.go │ │ │ ├── mock │ │ │ │ ├── kubernetes.go │ │ │ │ └── utils.go │ │ │ ├── utils.go │ │ │ └── watch │ │ │ │ ├── body.go │ │ │ │ ├── watch.go │ │ │ │ └── watch_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── kubernetes.go │ │ ├── kubernetes_test.go │ │ └── watcher.go │ ├── mdns │ │ ├── go.mod │ │ ├── go.sum │ │ └── mdns.go │ ├── memory │ │ ├── go.mod │ │ ├── go.sum │ │ └── memory.go │ ├── multi │ │ ├── go.mod │ │ ├── go.sum │ │ ├── multi.go │ │ ├── options.go │ │ └── watcher.go │ ├── nats │ │ ├── assert_test.go │ │ ├── environment_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nats.go │ │ ├── nats_test.go │ │ ├── options.go │ │ ├── options_test.go │ │ ├── util.go │ │ └── watcher.go │ ├── proxy │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── proxy.go │ │ └── watcher.go │ ├── service │ │ ├── go.mod │ │ ├── go.sum │ │ └── service.go │ └── zookeeper │ │ ├── go.mod │ │ ├── go.sum │ │ ├── util.go │ │ ├── watcher.go │ │ └── zookeeper.go ├── server │ └── http │ │ ├── README.md │ │ ├── buffer.go │ │ ├── context.go │ │ ├── extractor.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── handler.go │ │ ├── http.go │ │ ├── http_test.go │ │ ├── message.go │ │ ├── options.go │ │ └── subscriber.go ├── store │ ├── consul │ │ ├── consul.go │ │ ├── go.mod │ │ └── go.sum │ ├── etcd │ │ ├── config.go │ │ ├── etcd.go │ │ ├── etcd_test.go │ │ ├── go.mod │ │ └── go.sum │ ├── memcached │ │ ├── go.mod │ │ ├── go.sum │ │ └── memcached.go │ ├── mysql │ │ ├── go.mod │ │ ├── go.sum │ │ ├── mysql.go │ │ └── mysql_test.go │ └── redis │ │ ├── go.mod │ │ ├── go.sum │ │ ├── redis.go │ │ └── redis_test.go ├── transport │ ├── grpc │ │ ├── go.mod │ │ ├── go.sum │ │ └── grpc.go │ ├── http │ │ ├── go.mod │ │ ├── go.sum │ │ ├── http.go │ │ └── options.go │ ├── memory │ │ ├── go.mod │ │ ├── go.sum │ │ └── memory.go │ ├── nats │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nats.go │ │ ├── nats_test.go │ │ └── options.go │ ├── quic │ │ ├── go.mod │ │ ├── go.sum │ │ └── quic.go │ ├── rabbitmq │ │ ├── channel.go │ │ ├── connection.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── rabbitmq.go │ ├── tcp │ │ ├── go.mod │ │ ├── go.sum │ │ ├── tcp.go │ │ └── tcp_test.go │ └── utp │ │ ├── README.md │ │ ├── client.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── listener.go │ │ ├── socket.go │ │ ├── transport.go │ │ ├── utp.go │ │ └── utp_test.go └── wrapper │ ├── README.md │ ├── breaker │ ├── gobreaker │ │ ├── go.mod │ │ ├── go.sum │ │ ├── gobreaker.go │ │ └── gobreaker_test.go │ └── hystrix │ │ ├── go.mod │ │ ├── go.sum │ │ ├── hystrix.go │ │ └── hystrix_test.go │ ├── endpoint │ ├── README.md │ ├── endpoint.go │ ├── go.mod │ └── go.sum │ ├── monitoring │ ├── prometheus │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── prometheus.go │ │ └── prometheus_test.go │ └── victoriametrics │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── victoriametrics.go │ │ └── victoriametrics_test.go │ ├── ratelimiter │ ├── ratelimit │ │ ├── go.mod │ │ ├── go.sum │ │ ├── ratelimit.go │ │ └── ratelimit_test.go │ └── uber │ │ ├── go.mod │ │ ├── go.sum │ │ └── uber.go │ ├── select │ ├── roundrobin │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── roundrobin.go │ ├── shard │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── shard.go │ └── version │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── version.go │ ├── service │ ├── README.md │ ├── go.mod │ ├── go.sum │ └── service.go │ ├── trace │ ├── awsxray │ │ ├── README.md │ │ ├── awsxray.go │ │ ├── awsxray.png │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── util.go │ ├── datadog │ │ ├── datadog.go │ │ ├── datadog_test.go │ │ ├── ext.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── helper.go │ │ ├── stats.go │ │ ├── status.go │ │ └── tracker.go │ ├── opencensus │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── opencensus.go │ │ ├── stats.go │ │ ├── status.go │ │ └── tracker.go │ └── opentracing │ │ ├── go.mod │ │ ├── go.sum │ │ ├── opentracing.go │ │ └── opentracing_test.go │ └── validator │ ├── go.mod │ ├── go.sum │ └── validator.go ├── v3 ├── README.md ├── acme │ └── certmagic │ │ ├── certmagic.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── storage.go ├── auth │ └── jwt │ │ ├── go.mod │ │ ├── go.sum │ │ ├── jwt.go │ │ └── token │ │ ├── jwt.go │ │ ├── jwt_test.go │ │ ├── options.go │ │ ├── test │ │ ├── sample_key │ │ └── sample_key.pub │ │ └── token.go ├── broker │ ├── gocloud │ │ ├── go.mod │ │ ├── go.sum │ │ ├── gocloud.go │ │ ├── gocloud_test.go │ │ └── options.go │ ├── googlepubsub │ │ ├── go.mod │ │ ├── go.sum │ │ ├── googlepubsub.go │ │ └── options.go │ ├── grpc │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grpc.go │ │ ├── grpc_test.go │ │ └── proto │ │ │ ├── broker.pb.go │ │ │ └── broker.proto │ ├── http │ │ ├── go.mod │ │ ├── go.sum │ │ ├── http.go │ │ └── http_test.go │ ├── kafka │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── kafka.go │ │ └── options.go │ ├── memory │ │ ├── go.mod │ │ ├── go.sum │ │ ├── memory.go │ │ └── memory_test.go │ ├── mqtt │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── mqtt.go │ │ ├── mqtt_handler.go │ │ ├── mqtt_mock.go │ │ └── mqtt_test.go │ ├── nats │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nats.go │ │ ├── nats_test.go │ │ └── options.go │ ├── nsq │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nsq.go │ │ └── options.go │ ├── proxy │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── proxy.go │ │ ├── publication.go │ │ └── subscriber.go │ ├── rabbitmq │ │ ├── auth.go │ │ ├── channel.go │ │ ├── connection.go │ │ ├── connection_test.go │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── rabbitmq.go │ │ └── rabbitmq_test.go │ ├── redis │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── redis.go │ │ └── redis_test.go │ ├── segmentio │ │ ├── broker_test.go │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── sarama_test.go │ │ ├── segmentio.go │ │ └── segmentio_test.go │ ├── snssqs │ │ ├── README.md │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── snssqs.go │ │ ├── snssqs_test.go │ │ └── unicode.go │ ├── sqs │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── sqs.go │ ├── stan │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── stan.go │ │ └── stan_test.go │ └── stomp │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── publication.go │ │ ├── stomp.go │ │ └── subscriber.go ├── client │ ├── grpc │ │ ├── README.md │ │ ├── codec.go │ │ ├── error.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grpc.go │ │ ├── grpc_pool.go │ │ ├── grpc_pool_test.go │ │ ├── grpc_test.go │ │ ├── message.go │ │ ├── options.go │ │ ├── request.go │ │ ├── request_test.go │ │ ├── response.go │ │ └── stream.go │ ├── http │ │ ├── README.md │ │ ├── buffer.go │ │ ├── codec.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── http.go │ │ ├── http_test.go │ │ ├── message.go │ │ ├── request.go │ │ ├── stream.go │ │ └── test │ │ │ ├── test.pb.go │ │ │ └── test.proto │ ├── mock │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── mock.go │ │ ├── mock_test.go │ │ └── options.go │ └── mucp │ │ ├── go.mod │ │ ├── go.sum │ │ └── mucp.go ├── codec │ ├── bsonrpc │ │ ├── bsonrpc.go │ │ ├── codec.go │ │ ├── go.mod │ │ └── go.sum │ ├── json-iterator │ │ ├── go.mod │ │ ├── go.sum │ │ ├── json.go │ │ └── marshaler.go │ ├── jsonrpc2 │ │ ├── README.md │ │ ├── client.go │ │ ├── errors.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── jsonrpc2.go │ │ ├── license.go │ │ └── server.go │ ├── msgpackrpc │ │ ├── README.md │ │ ├── codec.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── rpc.go │ │ └── rpc_test.go │ └── segmentio │ │ ├── go.mod │ │ ├── go.sum │ │ ├── json.go │ │ └── marshaler.go ├── config │ ├── encoder │ │ ├── cue │ │ │ ├── cue.go │ │ │ ├── cue_test.go │ │ │ ├── go.mod │ │ │ └── go.sum │ │ ├── hcl │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── hcl.go │ │ ├── toml │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── toml.go │ │ ├── xml │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── xml.go │ │ └── yaml │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── yaml.go │ └── source │ │ ├── configmap │ │ ├── README.md │ │ ├── configmap.go │ │ ├── configmap_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── testdata │ │ │ ├── config │ │ │ ├── mongodb │ │ │ └── redis │ │ ├── util.go │ │ └── watcher.go │ │ ├── consul │ │ ├── README.md │ │ ├── consul.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── util.go │ │ └── watcher.go │ │ ├── etcd │ │ ├── README.md │ │ ├── etcd.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── util.go │ │ └── watcher.go │ │ ├── grpc │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grpc.go │ │ ├── options.go │ │ ├── proto │ │ │ ├── grpc.pb.go │ │ │ └── grpc.proto │ │ ├── util.go │ │ └── watcher.go │ │ ├── mucp │ │ ├── go.mod │ │ ├── go.sum │ │ ├── mucp.go │ │ ├── options.go │ │ ├── proto │ │ │ ├── mucp.micro.go │ │ │ ├── mucp.pb.go │ │ │ └── mucp.proto │ │ ├── util.go │ │ └── watcher.go │ │ ├── nacos │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nacos.go │ │ ├── options.go │ │ └── watcher.go │ │ ├── pkger │ │ ├── README.md │ │ ├── format.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── pkger.go │ │ ├── runtimevar │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── runtimevar.go │ │ └── watcher.go │ │ ├── url │ │ ├── README.md │ │ ├── format.go │ │ ├── format_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── url.go │ │ └── watcher.go │ │ └── vault │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── testdata │ │ └── vault_init_commands │ │ ├── util.go │ │ ├── vault.go │ │ ├── vault_test.go │ │ └── watcher.go ├── logger │ ├── apex │ │ ├── apex.go │ │ ├── apex_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── options.go │ ├── logrus │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── logrus.go │ │ ├── logrus_test.go │ │ └── options.go │ ├── windowseventlog │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── windowseventlog.go │ │ └── windowseventlog_test.go │ ├── zap │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── zap.go │ │ └── zap_test.go │ └── zerolog │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── zerolog.go │ │ └── zerolog_test.go ├── proxy │ └── http │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── http.go │ │ ├── http_test.go │ │ └── options.go ├── registry │ ├── cache │ │ ├── README.md │ │ ├── cache.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── options.go │ ├── consul │ │ ├── consul.go │ │ ├── encoding.go │ │ ├── encoding_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── registry_test.go │ │ ├── watcher.go │ │ └── watcher_test.go │ ├── etcd │ │ ├── etcd.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── watcher.go │ ├── eureka │ │ ├── eureka.go │ │ ├── eureka_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── marshalling.go │ │ ├── marshalling_test.go │ │ ├── mock │ │ │ └── fargo_conn.go │ │ ├── options.go │ │ ├── options_test.go │ │ └── watcher.go │ ├── gossip │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── gossip.go │ │ ├── gossip_test.go │ │ ├── options.go │ │ ├── proto │ │ │ ├── gossip.micro.go │ │ │ ├── gossip.pb.go │ │ │ └── gossip.proto │ │ └── watcher.go │ ├── kubernetes │ │ ├── README.md │ │ ├── client │ │ │ ├── api │ │ │ │ ├── api_test.go │ │ │ │ ├── request.go │ │ │ │ └── response.go │ │ │ ├── client.go │ │ │ ├── kubernetes.go │ │ │ ├── mock │ │ │ │ ├── kubernetes.go │ │ │ │ └── utils.go │ │ │ ├── utils.go │ │ │ └── watch │ │ │ │ ├── body.go │ │ │ │ ├── watch.go │ │ │ │ └── watch_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── kubernetes.go │ │ ├── kubernetes_test.go │ │ └── watcher.go │ ├── mdns │ │ ├── go.mod │ │ ├── go.sum │ │ └── mdns.go │ ├── memory │ │ ├── go.mod │ │ ├── go.sum │ │ ├── memory.go │ │ ├── memory_test.go │ │ ├── memory_watcher.go │ │ ├── options.go │ │ ├── util.go │ │ ├── watcher.go │ │ └── watcher_test.go │ ├── multi │ │ ├── go.mod │ │ ├── go.sum │ │ ├── multi.go │ │ ├── options.go │ │ └── watcher.go │ ├── nacos │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nacos.go │ │ ├── options.go │ │ └── watcher.go │ ├── nats │ │ ├── assert_test.go │ │ ├── environment_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nats.go │ │ ├── nats_test.go │ │ ├── options.go │ │ ├── options_test.go │ │ ├── util.go │ │ └── watcher.go │ ├── proxy │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── proxy.go │ │ └── watcher.go │ └── zookeeper │ │ ├── go.mod │ │ ├── go.sum │ │ ├── util.go │ │ ├── watcher.go │ │ └── zookeeper.go ├── selector │ ├── dns │ │ ├── dns.go │ │ ├── go.mod │ │ └── go.sum │ ├── label │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── label.go │ │ ├── label_test.go │ │ └── options.go │ ├── registry │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── registry.go │ ├── shard │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── shard.go │ │ └── shard_test.go │ └── static │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── static.go │ │ └── static_test.go ├── server │ ├── grpc │ │ ├── README.md │ │ ├── codec.go │ │ ├── context.go │ │ ├── error.go │ │ ├── extractor.go │ │ ├── extractor_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grpc.go │ │ ├── grpc_test.go │ │ ├── handler.go │ │ ├── options.go │ │ ├── proto │ │ │ ├── test.pb.go │ │ │ ├── test.pb.micro.go │ │ │ └── test.proto │ │ ├── request.go │ │ ├── response.go │ │ ├── server.go │ │ ├── stream.go │ │ ├── subscriber.go │ │ └── util.go │ ├── http │ │ ├── README.md │ │ ├── buffer.go │ │ ├── context.go │ │ ├── extractor.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── handler.go │ │ ├── http.go │ │ ├── http_test.go │ │ ├── message.go │ │ ├── options.go │ │ └── subscriber.go │ └── mucp │ │ ├── go.mod │ │ ├── go.sum │ │ └── mucp.go ├── store │ ├── cockroach │ │ ├── cockroach.go │ │ ├── cockroach_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── metadata.go │ ├── consul │ │ ├── consul.go │ │ ├── go.mod │ │ └── go.sum │ ├── file │ │ ├── file.go │ │ ├── file_test.go │ │ ├── go.mod │ │ └── go.sum │ ├── memcached │ │ ├── go.mod │ │ ├── go.sum │ │ └── memcached.go │ ├── memory │ │ ├── go.mod │ │ ├── go.sum │ │ ├── memory.go │ │ └── memory_test.go │ ├── mysql │ │ ├── go.mod │ │ ├── go.sum │ │ ├── mysql.go │ │ └── mysql_test.go │ └── redis │ │ ├── go.mod │ │ ├── go.sum │ │ ├── redis.go │ │ └── redis_test.go ├── sync │ ├── consul │ │ ├── consul.go │ │ ├── consul_test.go │ │ ├── go.mod │ │ └── go.sum │ ├── etcd │ │ ├── etcd.go │ │ ├── go.mod │ │ └── go.sum │ └── memory │ │ ├── go.mod │ │ ├── go.sum │ │ └── memory.go ├── transport │ ├── grpc │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grpc.go │ │ ├── grpc_test.go │ │ ├── handler.go │ │ ├── proto │ │ │ ├── transport.pb.go │ │ │ ├── transport.pb.micro.go │ │ │ └── transport.proto │ │ └── socket.go │ ├── http │ │ ├── go.mod │ │ ├── go.sum │ │ ├── http.go │ │ ├── http_test.go │ │ └── options.go │ ├── memory │ │ ├── go.mod │ │ ├── go.sum │ │ ├── memory.go │ │ └── memory_test.go │ ├── nats │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nats.go │ │ ├── nats_test.go │ │ └── options.go │ ├── quic │ │ ├── go.mod │ │ ├── go.sum │ │ └── quic.go │ ├── rabbitmq │ │ ├── channel.go │ │ ├── connection.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── rabbitmq.go │ ├── tcp │ │ ├── go.mod │ │ ├── go.sum │ │ ├── tcp.go │ │ └── tcp_test.go │ └── utp │ │ ├── README.md │ │ ├── client.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── listener.go │ │ ├── socket.go │ │ ├── transport.go │ │ ├── utp.go │ │ └── utp_test.go └── wrapper │ ├── README.md │ ├── breaker │ ├── gobreaker │ │ ├── go.mod │ │ ├── go.sum │ │ ├── gobreaker.go │ │ └── gobreaker_test.go │ └── hystrix │ │ ├── README.md │ │ ├── configure.go │ │ ├── configure_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── hystrix.go │ │ ├── hystrix_test.go │ │ └── options.go │ ├── endpoint │ ├── README.md │ ├── endpoint.go │ ├── go.mod │ └── go.sum │ ├── monitoring │ ├── prometheus │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── prometheus.go │ │ └── prometheus_test.go │ └── victoriametrics │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── victoriametrics.go │ │ └── victoriametrics_test.go │ ├── ratelimiter │ ├── ratelimit │ │ ├── go.mod │ │ ├── go.sum │ │ ├── ratelimit.go │ │ └── ratelimit_test.go │ └── uber │ │ ├── go.mod │ │ ├── go.sum │ │ └── uber.go │ ├── select │ ├── roundrobin │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── roundrobin.go │ ├── shard │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── shard.go │ └── version │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── version.go │ ├── service │ ├── README.md │ ├── go.mod │ ├── go.sum │ └── service.go │ ├── trace │ ├── awsxray │ │ ├── README.md │ │ ├── awsxray.go │ │ ├── awsxray.png │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── util.go │ ├── datadog │ │ ├── datadog.go │ │ ├── datadog_test.go │ │ ├── ext.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── helper.go │ │ ├── stats.go │ │ ├── status.go │ │ └── tracker.go │ ├── opencensus │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── opencensus.go │ │ ├── stats.go │ │ ├── status.go │ │ └── tracker.go │ └── opentracing │ │ ├── go.mod │ │ ├── go.sum │ │ ├── opentracing.go │ │ └── opentracing_test.go │ └── validator │ ├── go.mod │ ├── go.sum │ └── validator.go ├── v4 ├── README.md ├── acme │ └── certmagic │ │ ├── certmagic.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── storage.go ├── auth │ └── jwt │ │ ├── go.mod │ │ ├── go.sum │ │ ├── jwt.go │ │ └── token │ │ ├── jwt.go │ │ ├── jwt_test.go │ │ ├── options.go │ │ ├── test │ │ ├── sample_key │ │ ├── sample_key 2 │ │ └── sample_key.pub │ │ └── token.go ├── broker │ ├── gocloud │ │ ├── go.mod │ │ ├── go.sum │ │ ├── gocloud.go │ │ ├── gocloud_test.go │ │ └── options.go │ ├── googlepubsub │ │ ├── go.mod │ │ ├── go.sum │ │ ├── googlepubsub.go │ │ └── options.go │ ├── grpc │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grpc.go │ │ ├── grpc_test.go │ │ └── proto │ │ │ ├── broker.pb.go │ │ │ └── broker.proto │ ├── http │ │ ├── go.mod │ │ ├── go.sum │ │ ├── http.go │ │ └── http_test.go │ ├── kafka │ │ ├── README.md │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── kafka.go │ │ └── options.go │ ├── memory │ │ ├── go.mod │ │ ├── go.sum │ │ ├── memory.go │ │ └── memory_test.go │ ├── mqtt │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── mqtt.go │ │ ├── mqtt_handler.go │ │ ├── mqtt_mock.go │ │ └── mqtt_test.go │ ├── nats │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nats.go │ │ ├── nats_test.go │ │ └── options.go │ ├── nsq │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nsq.go │ │ └── options.go │ ├── proxy │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── proxy.go │ │ ├── publication.go │ │ └── subscriber.go │ ├── rabbitmq │ │ ├── auth.go │ │ ├── channel.go │ │ ├── connection.go │ │ ├── connection_test.go │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── rabbitmq.go │ │ └── rabbitmq_test.go │ ├── redis │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── redis.go │ │ └── redis_test.go │ ├── segmentio │ │ ├── broker_test.go │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── sarama_test.go │ │ ├── segmentio.go │ │ └── segmentio_test.go │ ├── snssqs │ │ ├── README.md │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── snssqs.go │ │ ├── snssqs_test.go │ │ └── unicode.go │ ├── sqs │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── sqs.go │ ├── stan │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── stan.go │ │ └── stan_test.go │ └── stomp │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── publication.go │ │ ├── stomp.go │ │ └── subscriber.go ├── cache │ └── redis │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── options_test.go │ │ ├── redis.go │ │ └── redis_test.go ├── client │ ├── grpc │ │ ├── README.md │ │ ├── codec.go │ │ ├── error.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grpc.go │ │ ├── grpc_pool.go │ │ ├── grpc_pool_test.go │ │ ├── grpc_test.go │ │ ├── message.go │ │ ├── options.go │ │ ├── request.go │ │ ├── request_test.go │ │ ├── response.go │ │ └── stream.go │ ├── http │ │ ├── README.md │ │ ├── buffer.go │ │ ├── codec.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── http.go │ │ ├── http_test.go │ │ ├── message.go │ │ ├── request.go │ │ ├── stream.go │ │ └── test │ │ │ ├── test.pb.go │ │ │ └── test.proto │ ├── mock │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── mock.go │ │ ├── mock_test.go │ │ └── options.go │ └── mucp │ │ ├── go.mod │ │ ├── go.sum │ │ └── mucp.go ├── codec │ ├── bsonrpc │ │ ├── bsonrpc.go │ │ ├── codec.go │ │ ├── go.mod │ │ └── go.sum │ ├── json-iterator │ │ ├── go.mod │ │ ├── go.sum │ │ ├── json.go │ │ └── marshaler.go │ ├── jsonrpc2 │ │ ├── README.md │ │ ├── client.go │ │ ├── errors.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── license.go │ │ └── server.go │ ├── msgpackrpc │ │ ├── README.md │ │ ├── codec.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── rpc.go │ │ └── rpc_test.go │ └── segmentio │ │ ├── go.mod │ │ ├── go.sum │ │ ├── json.go │ │ └── marshaler.go ├── config │ ├── encoder │ │ ├── cue │ │ │ ├── cue.go │ │ │ ├── cue_test.go │ │ │ ├── go.mod │ │ │ └── go.sum │ │ ├── hcl │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── hcl.go │ │ ├── toml │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── toml.go │ │ ├── xml │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── xml.go │ │ └── yaml │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── yaml.go │ └── source │ │ ├── configmap │ │ ├── README.md │ │ ├── configmap.go │ │ ├── configmap_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── testdata │ │ │ ├── config │ │ │ ├── config 2 │ │ │ ├── mongodb │ │ │ ├── mongodb 2 │ │ │ ├── redis │ │ │ └── redis 2 │ │ ├── util.go │ │ └── watcher.go │ │ ├── consul │ │ ├── README.md │ │ ├── consul.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── util.go │ │ └── watcher.go │ │ ├── etcd │ │ ├── README.md │ │ ├── etcd.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── util.go │ │ └── watcher.go │ │ ├── grpc │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grpc.go │ │ ├── options.go │ │ ├── proto │ │ │ ├── grpc.pb.go │ │ │ └── grpc.proto │ │ ├── util.go │ │ └── watcher.go │ │ ├── mucp │ │ ├── go.mod │ │ ├── go.sum │ │ ├── mucp.go │ │ ├── options.go │ │ ├── proto │ │ │ ├── mucp.micro.go │ │ │ ├── mucp.pb.go │ │ │ └── mucp.proto │ │ ├── util.go │ │ └── watcher.go │ │ ├── nacos │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nacos.go │ │ ├── options.go │ │ └── watcher.go │ │ ├── nats │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nats.go │ │ ├── options.go │ │ └── watcher.go │ │ ├── pkger │ │ ├── README.md │ │ ├── format.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── pkger.go │ │ ├── runtimevar │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── runtimevar.go │ │ └── watcher.go │ │ ├── url │ │ ├── README.md │ │ ├── format.go │ │ ├── format_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── url.go │ │ └── watcher.go │ │ └── vault │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── testdata │ │ ├── vault_init_commands │ │ └── vault_init_commands 2 │ │ ├── util.go │ │ ├── vault.go │ │ ├── vault_test.go │ │ └── watcher.go ├── events │ ├── nats │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nats.go │ │ └── options.go │ ├── natsjs │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── helpers_test.go │ │ ├── nats.go │ │ ├── nats_test.go │ │ └── options.go │ └── redis │ │ ├── go.mod │ │ ├── go.sum │ │ ├── janitor.go │ │ ├── options.go │ │ ├── options_test.go │ │ ├── redis.go │ │ └── redis_test.go ├── logger │ ├── apex │ │ ├── apex.go │ │ ├── apex_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── options.go │ ├── logrus │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── logrus.go │ │ ├── logrus_test.go │ │ └── options.go │ ├── windowseventlog │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── windowseventlog.go │ │ └── windowseventlog_test.go │ ├── zap │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── zap.go │ │ └── zap_test.go │ └── zerolog │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── zerolog.go │ │ └── zerolog_test.go ├── proxy │ └── http │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── http.go │ │ ├── http_test.go │ │ └── options.go ├── registry │ ├── cache │ │ ├── README.md │ │ ├── cache.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── options.go │ ├── consul │ │ ├── consul.go │ │ ├── encoding.go │ │ ├── encoding_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── registry_test.go │ │ ├── watcher.go │ │ └── watcher_test.go │ ├── etcd │ │ ├── etcd.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── watcher.go │ ├── eureka │ │ ├── eureka.go │ │ ├── eureka_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── marshalling.go │ │ ├── marshalling_test.go │ │ ├── mock │ │ │ └── fargo_conn.go │ │ ├── options.go │ │ ├── options_test.go │ │ └── watcher.go │ ├── gossip │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── gossip.go │ │ ├── gossip_test.go │ │ ├── options.go │ │ ├── proto │ │ │ ├── gossip.micro.go │ │ │ ├── gossip.pb.go │ │ │ └── gossip.proto │ │ └── watcher.go │ ├── kubernetes │ │ ├── README.md │ │ ├── client │ │ │ ├── api │ │ │ │ ├── api_test.go │ │ │ │ ├── request.go │ │ │ │ └── response.go │ │ │ ├── client.go │ │ │ ├── kubernetes.go │ │ │ ├── mock │ │ │ │ ├── kubernetes.go │ │ │ │ └── utils.go │ │ │ ├── utils.go │ │ │ └── watch │ │ │ │ ├── body.go │ │ │ │ ├── watch.go │ │ │ │ └── watch_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── kubernetes.go │ │ ├── kubernetes_test.go │ │ └── watcher.go │ ├── mdns │ │ ├── go.mod │ │ ├── go.sum │ │ └── mdns.go │ ├── memory │ │ ├── go.mod │ │ ├── go.sum │ │ ├── memory.go │ │ ├── memory_test.go │ │ ├── memory_watcher.go │ │ ├── options.go │ │ ├── util.go │ │ ├── watcher.go │ │ └── watcher_test.go │ ├── multi │ │ ├── go.mod │ │ ├── go.sum │ │ ├── multi.go │ │ ├── options.go │ │ └── watcher.go │ ├── nacos │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nacos.go │ │ ├── options.go │ │ └── watcher.go │ ├── nats │ │ ├── assert_test.go │ │ ├── environment_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nats.go │ │ ├── nats_test.go │ │ ├── options.go │ │ ├── options_test.go │ │ ├── util.go │ │ └── watcher.go │ ├── polaris │ │ ├── README.md │ │ ├── assert_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── polaris.go │ │ ├── polaris_test.go │ │ └── watcher.go │ ├── proxy │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── proxy.go │ │ └── watcher.go │ └── zookeeper │ │ ├── go.mod │ │ ├── go.sum │ │ ├── util.go │ │ ├── watcher.go │ │ └── zookeeper.go ├── selector │ ├── dns │ │ ├── dns.go │ │ ├── go.mod │ │ └── go.sum │ ├── label │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── label.go │ │ ├── label_test.go │ │ └── options.go │ ├── registry │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── registry.go │ ├── shard │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── shard.go │ │ └── shard_test.go │ └── static │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── static.go │ │ └── static_test.go ├── server │ ├── grpc │ │ ├── README.md │ │ ├── codec.go │ │ ├── context.go │ │ ├── error.go │ │ ├── extractor.go │ │ ├── extractor_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grpc.go │ │ ├── grpc_test.go │ │ ├── handler.go │ │ ├── options.go │ │ ├── proto │ │ │ ├── test.pb.go │ │ │ ├── test.pb.micro.go │ │ │ └── test.proto │ │ ├── request.go │ │ ├── response.go │ │ ├── server.go │ │ ├── stream.go │ │ ├── subscriber.go │ │ └── util.go │ ├── http │ │ ├── README.md │ │ ├── buffer.go │ │ ├── context.go │ │ ├── extractor.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── handler.go │ │ ├── http.go │ │ ├── http_test.go │ │ ├── message.go │ │ ├── options.go │ │ └── subscriber.go │ └── mucp │ │ ├── go.mod │ │ ├── go.sum │ │ └── mucp.go ├── store │ ├── cockroach │ │ ├── cockroach.go │ │ ├── cockroach_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── metadata.go │ ├── consul │ │ ├── consul.go │ │ ├── go.mod │ │ └── go.sum │ ├── file │ │ ├── file.go │ │ ├── file_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── options.go │ ├── memcached │ │ ├── go.mod │ │ ├── go.sum │ │ └── memcached.go │ ├── memory │ │ ├── go.mod │ │ ├── go.sum │ │ ├── memory.go │ │ └── memory_test.go │ ├── mysql │ │ ├── go.mod │ │ ├── go.sum │ │ ├── mysql.go │ │ └── mysql_test.go │ ├── nats-js-kv │ │ ├── README.md │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── helpers_test.go │ │ ├── keys.go │ │ ├── nats.go │ │ ├── nats_test.go │ │ ├── options.go │ │ └── test_data.go │ ├── nats-js │ │ ├── README.md │ │ ├── context.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── helpers_test.go │ │ ├── nats.go │ │ ├── nats_test.go │ │ ├── options.go │ │ └── test_data.go │ └── redis │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ ├── redis.go │ │ └── redis_test.go ├── sync │ ├── consul │ │ ├── consul.go │ │ ├── consul_test.go │ │ ├── go.mod │ │ └── go.sum │ ├── etcd │ │ ├── etcd.go │ │ ├── go.mod │ │ └── go.sum │ └── memory │ │ ├── go.mod │ │ ├── go.sum │ │ └── memory.go ├── transport │ ├── grpc │ │ ├── go.mod │ │ ├── go.sum │ │ ├── grpc.go │ │ ├── grpc_test.go │ │ ├── handler.go │ │ ├── proto │ │ │ ├── transport.pb.go │ │ │ ├── transport.pb.micro.go │ │ │ └── transport.proto │ │ └── socket.go │ ├── http │ │ ├── go.mod │ │ ├── go.sum │ │ ├── http.go │ │ ├── http_test.go │ │ └── options.go │ ├── memory │ │ ├── go.mod │ │ ├── go.sum │ │ ├── memory.go │ │ └── memory_test.go │ ├── nats │ │ ├── go.mod │ │ ├── go.sum │ │ ├── nats.go │ │ ├── nats_test.go │ │ └── options.go │ ├── quic │ │ ├── go.mod │ │ ├── go.sum │ │ └── quic.go │ ├── rabbitmq │ │ ├── channel.go │ │ ├── connection.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── rabbitmq.go │ ├── tcp │ │ ├── go.mod │ │ ├── go.sum │ │ ├── tcp.go │ │ └── tcp_test.go │ └── utp │ │ ├── README.md │ │ ├── client.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── listener.go │ │ ├── socket.go │ │ ├── transport.go │ │ ├── utp.go │ │ └── utp_test.go └── wrapper │ ├── README.md │ ├── breaker │ ├── gobreaker │ │ ├── go.mod │ │ ├── go.sum │ │ ├── gobreaker.go │ │ └── gobreaker_test.go │ └── hystrix │ │ ├── README.md │ │ ├── configure.go │ │ ├── configure_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── hystrix.go │ │ ├── hystrix_test.go │ │ └── options.go │ ├── endpoint │ ├── README.md │ ├── endpoint.go │ ├── go.mod │ └── go.sum │ ├── monitoring │ ├── prometheus │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── prometheus.go │ │ └── prometheus_test.go │ └── victoriametrics │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── victoriametrics.go │ │ └── victoriametrics_test.go │ ├── ratelimiter │ ├── ratelimit │ │ ├── go.mod │ │ ├── go.sum │ │ ├── ratelimit.go │ │ └── ratelimit_test.go │ └── uber │ │ ├── go.mod │ │ ├── go.sum │ │ └── uber.go │ ├── select │ ├── roundrobin │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── roundrobin.go │ ├── shard │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── shard.go │ └── version │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ └── version.go │ ├── service │ ├── README.md │ ├── go.mod │ ├── go.sum │ └── service.go │ ├── trace │ ├── awsxray │ │ ├── README.md │ │ ├── awsxray.go │ │ ├── awsxray.png │ │ ├── go.mod │ │ ├── go.sum │ │ ├── options.go │ │ └── util.go │ ├── datadog │ │ ├── datadog.go │ │ ├── datadog_test.go │ │ ├── ext.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── helper.go │ │ ├── stats.go │ │ ├── status.go │ │ └── tracker.go │ ├── opencensus │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── opencensus.go │ │ ├── stats.go │ │ ├── status.go │ │ └── tracker.go │ ├── opentelemetry │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── opentelemetry.go │ │ ├── options.go │ │ └── wrapper.go │ └── opentracing │ │ ├── go.mod │ │ ├── go.sum │ │ ├── opentracing.go │ │ └── opentracing_test.go │ └── validator │ ├── go.mod │ ├── go.sum │ └── validator.go └── v5 ├── README.md ├── auth └── jwt │ ├── go.mod │ ├── go.sum │ ├── jwt.go │ └── token │ ├── jwt.go │ ├── jwt_test.go │ ├── options.go │ ├── test │ ├── sample_key │ ├── sample_key 2 │ └── sample_key.pub │ └── token.go ├── broker ├── gocloud │ ├── go.mod │ ├── go.sum │ ├── gocloud.go │ ├── gocloud_test.go │ └── options.go ├── googlepubsub │ ├── go.mod │ ├── go.sum │ ├── googlepubsub.go │ └── options.go ├── grpc │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── grpc.go │ ├── grpc_test.go │ └── proto │ │ ├── broker.pb.go │ │ └── broker.proto ├── http │ ├── go.mod │ ├── go.sum │ ├── http.go │ └── http_test.go ├── kafka │ ├── README.md │ ├── context.go │ ├── go.mod │ ├── go.sum │ ├── kafka.go │ └── options.go ├── memory │ ├── go.mod │ ├── go.sum │ ├── memory.go │ └── memory_test.go ├── mqtt │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── mqtt.go │ ├── mqtt_handler.go │ ├── mqtt_mock.go │ └── mqtt_test.go ├── nats │ ├── context.go │ ├── go.mod │ ├── go.sum │ ├── nats.go │ ├── nats_test.go │ └── options.go ├── nsq │ ├── go.mod │ ├── go.sum │ ├── nsq.go │ └── options.go ├── proxy │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── proxy.go │ ├── publication.go │ └── subscriber.go ├── rabbitmq │ ├── auth.go │ ├── channel.go │ ├── connection.go │ ├── connection_test.go │ ├── context.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── rabbitmq.go │ └── rabbitmq_test.go ├── redis │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── redis.go │ └── redis_test.go ├── segmentio │ ├── broker_test.go │ ├── context.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── sarama_test.go │ ├── segmentio.go │ └── segmentio_test.go ├── snssqs │ ├── README.md │ ├── context.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── snssqs.go │ ├── snssqs_test.go │ └── unicode.go ├── sqs │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── options.go │ └── sqs.go ├── stan │ ├── context.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── stan.go │ └── stan_test.go └── stomp │ ├── context.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── publication.go │ ├── stomp.go │ └── subscriber.go ├── cache └── redis │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── options_test.go │ ├── redis.go │ └── redis_test.go ├── client ├── grpc │ ├── README.md │ ├── codec.go │ ├── error.go │ ├── go.mod │ ├── go.sum │ ├── grpc.go │ ├── grpc_pool.go │ ├── grpc_pool_test.go │ ├── grpc_test.go │ ├── message.go │ ├── options.go │ ├── request.go │ ├── request_test.go │ ├── response.go │ └── stream.go ├── http │ ├── README.md │ ├── buffer.go │ ├── codec.go │ ├── go.mod │ ├── go.sum │ ├── http.go │ ├── http_test.go │ ├── message.go │ ├── request.go │ ├── stream.go │ └── test │ │ ├── test.pb.go │ │ └── test.proto ├── mock │ ├── context.go │ ├── go.mod │ ├── go.sum │ ├── mock.go │ ├── mock_test.go │ └── options.go └── mucp │ ├── go.mod │ ├── go.sum │ └── mucp.go ├── codec ├── json-iterator │ ├── go.mod │ ├── go.sum │ ├── json.go │ └── marshaler.go ├── jsonrpc2 │ ├── README.md │ ├── client.go │ ├── errors.go │ ├── go.mod │ ├── go.sum │ ├── license.go │ └── server.go ├── msgpackrpc │ ├── README.md │ ├── codec.go │ ├── go.mod │ ├── go.sum │ ├── rpc.go │ └── rpc_test.go └── segmentio │ ├── go.mod │ ├── go.sum │ ├── json.go │ └── marshaler.go ├── config ├── encoder │ ├── cue │ │ ├── cue.go │ │ ├── cue_test.go │ │ ├── go.mod │ │ └── go.sum │ ├── hcl │ │ ├── go.mod │ │ ├── go.sum │ │ └── hcl.go │ ├── toml │ │ ├── go.mod │ │ ├── go.sum │ │ └── toml.go │ ├── xml │ │ ├── go.mod │ │ ├── go.sum │ │ └── xml.go │ └── yaml │ │ ├── go.mod │ │ ├── go.sum │ │ └── yaml.go └── source │ ├── configmap │ ├── README.md │ ├── configmap.go │ ├── configmap_test.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── testdata │ │ ├── config │ │ ├── config 2 │ │ ├── mongodb │ │ ├── mongodb 2 │ │ ├── redis │ │ └── redis 2 │ ├── util.go │ └── watcher.go │ ├── consul │ ├── README.md │ ├── consul.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── util.go │ └── watcher.go │ ├── etcd │ ├── README.md │ ├── etcd.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── util.go │ └── watcher.go │ ├── grpc │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── grpc.go │ ├── options.go │ ├── proto │ │ ├── grpc.pb.go │ │ └── grpc.proto │ ├── util.go │ └── watcher.go │ ├── mucp │ ├── go.mod │ ├── go.sum │ ├── mucp.go │ ├── options.go │ ├── proto │ │ ├── mucp.micro.go │ │ ├── mucp.pb.go │ │ └── mucp.proto │ ├── util.go │ └── watcher.go │ ├── nacos │ ├── go.mod │ ├── go.sum │ ├── nacos.go │ ├── options.go │ └── watcher.go │ ├── nats │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── nats.go │ ├── options.go │ └── watcher.go │ ├── pkger │ ├── README.md │ ├── format.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ └── pkger.go │ ├── runtimevar │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── runtimevar.go │ └── watcher.go │ ├── url │ ├── README.md │ ├── format.go │ ├── format_test.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── url.go │ └── watcher.go │ └── vault │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── testdata │ ├── vault_init_commands │ └── vault_init_commands 2 │ ├── util.go │ ├── vault.go │ ├── vault_test.go │ └── watcher.go ├── logger ├── apex │ ├── apex.go │ ├── apex_test.go │ ├── go.mod │ ├── go.sum │ └── options.go ├── logrus │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── logrus.go │ ├── logrus_test.go │ └── options.go ├── windowseventlog │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── windowseventlog.go │ └── windowseventlog_test.go ├── zap │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── zap.go │ └── zap_test.go └── zerolog │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── zerolog.go │ └── zerolog_test.go ├── proxy └── http │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── http.go │ ├── http_test.go │ └── options.go ├── registry ├── cache │ ├── README.md │ ├── cache.go │ ├── go.mod │ ├── go.sum │ └── options.go ├── consul │ ├── consul.go │ ├── encoding.go │ ├── encoding_test.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── registry_test.go │ ├── watcher.go │ └── watcher_test.go ├── etcd │ ├── etcd.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ └── watcher.go ├── eureka │ ├── eureka.go │ ├── eureka_test.go │ ├── go.mod │ ├── go.sum │ ├── marshalling.go │ ├── marshalling_test.go │ ├── mock │ │ └── fargo_conn.go │ ├── options.go │ ├── options_test.go │ └── watcher.go ├── gossip │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── gossip.go │ ├── gossip_test.go │ ├── options.go │ ├── proto │ │ ├── gossip.micro.go │ │ ├── gossip.pb.go │ │ └── gossip.proto │ └── watcher.go ├── kubernetes │ ├── README.md │ ├── client │ │ ├── api │ │ │ ├── api_test.go │ │ │ ├── request.go │ │ │ └── response.go │ │ ├── client.go │ │ ├── kubernetes.go │ │ ├── mock │ │ │ ├── kubernetes.go │ │ │ └── utils.go │ │ ├── utils.go │ │ └── watch │ │ │ ├── body.go │ │ │ ├── watch.go │ │ │ └── watch_test.go │ ├── go.mod │ ├── go.sum │ ├── kubernetes.go │ ├── kubernetes_test.go │ └── watcher.go ├── mdns │ ├── go.mod │ ├── go.sum │ └── mdns.go ├── memory │ ├── go.mod │ ├── go.sum │ ├── memory.go │ ├── memory_test.go │ ├── memory_watcher.go │ ├── options.go │ ├── util.go │ ├── watcher.go │ └── watcher_test.go ├── multi │ ├── go.mod │ ├── go.sum │ ├── multi.go │ ├── options.go │ └── watcher.go ├── nacos │ ├── go.mod │ ├── go.sum │ ├── nacos.go │ ├── options.go │ └── watcher.go ├── nats │ ├── assert_test.go │ ├── environment_test.go │ ├── go.mod │ ├── go.sum │ ├── nats.go │ ├── nats_test.go │ ├── options.go │ ├── options_test.go │ ├── util.go │ └── watcher.go ├── polaris │ ├── README.md │ ├── assert_test.go │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── polaris.go │ ├── polaris_test.go │ └── watcher.go ├── proxy │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── proxy.go │ └── watcher.go └── zookeeper │ ├── go.mod │ ├── go.sum │ ├── util.go │ ├── watcher.go │ └── zookeeper.go ├── selector ├── dns │ ├── dns.go │ ├── go.mod │ └── go.sum ├── label │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── label.go │ ├── label_test.go │ └── options.go ├── registry │ ├── go.mod │ ├── go.sum │ ├── options.go │ └── registry.go ├── shard │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── shard.go │ └── shard_test.go └── static │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── static.go │ └── static_test.go ├── server ├── grpc │ ├── README.md │ ├── codec.go │ ├── context.go │ ├── error.go │ ├── extractor.go │ ├── extractor_test.go │ ├── go.mod │ ├── go.sum │ ├── grpc.go │ ├── handler.go │ ├── options.go │ ├── request.go │ ├── response.go │ ├── server.go │ ├── stream.go │ ├── subscriber.go │ └── util.go ├── http │ ├── README.md │ ├── buffer.go │ ├── context.go │ ├── extractor.go │ ├── go.mod │ ├── go.sum │ ├── handler.go │ ├── http.go │ ├── http_test.go │ ├── message.go │ ├── options.go │ └── subscriber.go └── mucp │ ├── go.mod │ ├── go.sum │ └── mucp.go ├── store ├── cockroach │ ├── cockroach.go │ ├── cockroach_test.go │ ├── go.mod │ ├── go.sum │ └── metadata.go ├── consul │ ├── consul.go │ ├── go.mod │ └── go.sum ├── file │ ├── file.go │ ├── file_test.go │ ├── go.mod │ ├── go.sum │ └── options.go ├── memcached │ ├── go.mod │ ├── go.sum │ └── memcached.go ├── memory │ ├── go.mod │ ├── go.sum │ ├── memory.go │ └── memory_test.go ├── mysql │ ├── go.mod │ ├── go.sum │ ├── mysql.go │ └── mysql_test.go ├── nats-js-kv │ ├── README.md │ ├── context.go │ ├── go.mod │ ├── go.sum │ ├── helpers_test.go │ ├── keys.go │ ├── nats.go │ ├── nats_test.go │ ├── options.go │ └── test_data.go ├── nats-js │ ├── README.md │ ├── context.go │ ├── go.mod │ ├── go.sum │ ├── helpers_test.go │ ├── nats.go │ ├── nats_test.go │ ├── options.go │ └── test_data.go └── redis │ ├── go.mod │ ├── go.sum │ ├── options.go │ ├── redis.go │ └── redis_test.go ├── transport ├── grpc │ ├── go.mod │ ├── go.sum │ ├── grpc.go │ ├── grpc_test.go │ ├── handler.go │ ├── proto │ │ ├── transport.pb.go │ │ ├── transport.pb.micro.go │ │ └── transport.proto │ └── socket.go ├── http │ ├── go.mod │ ├── go.sum │ ├── http.go │ ├── http_test.go │ └── options.go ├── memory │ ├── go.mod │ ├── go.sum │ ├── memory.go │ └── memory_test.go ├── nats │ ├── go.mod │ ├── go.sum │ ├── nats.go │ ├── nats_test.go │ └── options.go ├── quic │ ├── go.mod │ ├── go.sum │ └── quic.go ├── rabbitmq │ ├── channel.go │ ├── connection.go │ ├── go.mod │ ├── go.sum │ └── rabbitmq.go ├── tcp │ ├── go.mod │ ├── go.sum │ ├── tcp.go │ └── tcp_test.go └── utp │ ├── README.md │ ├── client.go │ ├── go.mod │ ├── go.sum │ ├── listener.go │ ├── socket.go │ ├── transport.go │ ├── utp.go │ └── utp_test.go └── wrapper ├── README.md ├── breaker ├── gobreaker │ ├── go.mod │ ├── go.sum │ ├── gobreaker.go │ └── gobreaker_test.go └── hystrix │ ├── README.md │ ├── configure.go │ ├── configure_test.go │ ├── go.mod │ ├── go.sum │ ├── hystrix.go │ ├── hystrix_test.go │ └── options.go ├── endpoint ├── README.md ├── endpoint.go ├── go.mod └── go.sum ├── monitoring ├── prometheus │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── prometheus.go │ └── prometheus_test.go └── victoriametrics │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── victoriametrics.go │ └── victoriametrics_test.go ├── ratelimiter ├── ratelimit │ ├── go.mod │ ├── go.sum │ ├── ratelimit.go │ └── ratelimit_test.go └── uber │ ├── go.mod │ ├── go.sum │ └── uber.go ├── select ├── roundrobin │ ├── README.md │ ├── go.mod │ ├── go.sum │ └── roundrobin.go ├── shard │ ├── README.md │ ├── go.mod │ ├── go.sum │ └── shard.go └── version │ ├── README.md │ ├── go.mod │ ├── go.sum │ └── version.go ├── service ├── README.md ├── go.mod ├── go.sum └── service.go ├── trace ├── awsxray │ ├── README.md │ ├── awsxray.go │ ├── awsxray.png │ ├── go.mod │ ├── go.sum │ ├── options.go │ └── util.go ├── datadog │ ├── datadog.go │ ├── datadog_test.go │ ├── ext.go │ ├── go.mod │ ├── go.sum │ ├── helper.go │ ├── stats.go │ ├── status.go │ └── tracker.go ├── opencensus │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── opencensus.go │ ├── stats.go │ ├── status.go │ └── tracker.go ├── opentelemetry │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── opentelemetry.go │ ├── options.go │ └── wrapper.go └── opentracing │ ├── go.mod │ ├── go.sum │ ├── opentracing.go │ └── opentracing_test.go └── validator ├── go.mod ├── go.sum └── validator.go /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | workflow_dispatch: 4 | inputs: 5 | releasePackages: 6 | description: 'Release Packages' 7 | required: true 8 | default: 'all' 9 | 10 | jobs: 11 | release: 12 | name: Release 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@v3 16 | with: 17 | fetch-depth: 0 18 | - name: Release Packages 19 | run: ./scripts/release.sh "${{ github.event.inputs.releasePackages }}" 20 | env: 21 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | Thumbs.db 2 | .DS_Store 3 | *.swp 4 | 5 | /.vscode/ 6 | /.idea/ 7 | .vim/ 8 | 9 | *coverage.out 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | fmt: 2 | @sh scripts/fmt.sh 3 | 4 | test: 5 | @sh scripts/test.sh v4 6 | 7 | upgrade-go-micro: 8 | @sh scripts/upgrade-go-micro.sh v4 latest -------------------------------------------------------------------------------- /scripts/fmt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | 3 | version=$1 4 | 5 | if [ "x$version" = "x" ]; then 6 | version='*' 7 | fi 8 | 9 | for d in $(find $version -name 'go.mod'); do 10 | pushd $(dirname $d) 11 | go mod tidy -go=1.16 && go mod tidy -go=1.17 12 | go fmt 13 | popd 14 | done 15 | -------------------------------------------------------------------------------- /scripts/gowork.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | 3 | for d in $(find * -name 'go.mod' -type f | sed -r 's|/[^/]+$||' | sort -u); do 4 | go work use $d 5 | done -------------------------------------------------------------------------------- /scripts/template/changelog.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | -------------------------------------------------------------------------------- /scripts/upgrade-go-micro.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -ex 2 | 3 | version=$1 4 | gomicro_version=$2 5 | 6 | if [ -z "$version" ]; then 7 | version='*' 8 | fi 9 | 10 | if [ -z "$gomicro_version" ]; then 11 | gomicro_version='latest' 12 | fi 13 | 14 | for d in $(find $version -name 'go.mod'); do 15 | pushd $(dirname $d) 16 | go get go-micro.dev/v4@"$gomicro_version" 17 | go mod tidy 18 | popd 19 | done 20 | -------------------------------------------------------------------------------- /v2/agent/README.md: -------------------------------------------------------------------------------- 1 | # Bot Plugins 2 | 3 | The micro bot is pluggable via Inputs and Commands. Read more about the bot in the blog post 4 | [micro.mu/blog/2016/04/25/the-micro-bot.html](https://micro.mu/blog/2016/04/25/the-micro-bot.html). 5 | 6 | Learn more about the bot plugins at [github.com/micro/micro/bot](https://github.com/micro/micro/tree/master/bot). 7 | -------------------------------------------------------------------------------- /v2/agent/command/animate/animate_test.go: -------------------------------------------------------------------------------- 1 | package animate 2 | 3 | // import ( 4 | // "testing" 5 | // ) 6 | 7 | // func TestAnimate(t *testing.T) { 8 | // // TODO: fix test 9 | // return 10 | 11 | // testData := []struct { 12 | // text string 13 | // }{ 14 | // {"funny cat"}, 15 | // } 16 | 17 | // command := Animate() 18 | 19 | // for _, d := range testData { 20 | // rsp, err := command.Exec("animate", d.text) 21 | // if err != nil { 22 | // t.Error(err) 23 | // } 24 | 25 | // if rsp == nil { 26 | // t.Error("expected result, got nil") 27 | // } 28 | // } 29 | // } 30 | -------------------------------------------------------------------------------- /v2/agent/command/animate/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/agent/command/animate 2 | 3 | go 1.17 4 | 5 | require github.com/micro/go-micro/v2 v2.9.1 6 | 7 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 8 | -------------------------------------------------------------------------------- /v2/agent/command/geocode/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/agent/command/geocode 2 | 3 | go 1.17 4 | 5 | require github.com/micro/go-micro/v2 v2.9.1 6 | 7 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 8 | -------------------------------------------------------------------------------- /v2/agent/command/whereareyou/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/agent/command/whereareyou 2 | 3 | go 1.17 4 | 5 | require github.com/micro/go-micro/v2 v2.9.1 6 | 7 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 8 | -------------------------------------------------------------------------------- /v2/broker/grpc/proto/broker.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package broker; 4 | 5 | service Broker { 6 | rpc Publish(Message) returns (Empty) {} 7 | } 8 | 9 | message Message { 10 | string topic = 1; 11 | string id = 2; 12 | map header = 3; 13 | bytes body = 4; 14 | } 15 | 16 | message Empty {} 17 | -------------------------------------------------------------------------------- /v2/broker/memory/memory.go: -------------------------------------------------------------------------------- 1 | // Package memory provides a memory broker 2 | package memory 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/broker" 6 | "github.com/micro/go-micro/v2/broker/memory" 7 | "github.com/micro/go-micro/v2/config/cmd" 8 | ) 9 | 10 | func init() { 11 | cmd.DefaultBrokers["memory"] = NewBroker 12 | } 13 | 14 | func NewBroker(opts ...broker.Option) broker.Broker { 15 | return memory.NewBroker(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v2/broker/nats/nats.go: -------------------------------------------------------------------------------- 1 | // Package memory provides a memory broker 2 | package memory 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/broker" 6 | "github.com/micro/go-micro/v2/broker/nats" 7 | "github.com/micro/go-micro/v2/config/cmd" 8 | ) 9 | 10 | func init() { 11 | cmd.DefaultBrokers["nats"] = NewBroker 12 | } 13 | 14 | func NewBroker(opts ...broker.Option) broker.Broker { 15 | return nats.NewBroker(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v2/broker/proxy/README.md: -------------------------------------------------------------------------------- 1 | # Proxy Broker 2 | 3 | This is a broker plugin for the micro [proxy](https://micro.mu/docs/proxy.html) 4 | 5 | ## Usage 6 | 7 | Here's a simple usage guide 8 | 9 | ### Run Proxy 10 | 11 | ``` 12 | # install micro 13 | go get github.com/micro/micro 14 | 15 | # run proxy 16 | micro proxy 17 | ``` 18 | 19 | ### Import and Flag plugin 20 | 21 | ``` 22 | import _ "github.com/go-micro/plugins/v2/broker/proxy" 23 | ``` 24 | 25 | ``` 26 | go run main.go --broker=proxy 27 | ``` 28 | -------------------------------------------------------------------------------- /v2/broker/proxy/publication.go: -------------------------------------------------------------------------------- 1 | package proxy 2 | 3 | import ( 4 | "github.com/micro/go-micro/v2/broker" 5 | ) 6 | 7 | type publication struct { 8 | topic string 9 | message *broker.Message 10 | err error 11 | } 12 | 13 | func (p *publication) Topic() string { 14 | return p.topic 15 | } 16 | 17 | func (p *publication) Message() *broker.Message { 18 | return p.message 19 | } 20 | 21 | func (p *publication) Ack() error { 22 | return nil 23 | } 24 | 25 | func (p *publication) Error() error { 26 | return p.err 27 | } 28 | -------------------------------------------------------------------------------- /v2/broker/rabbitmq/auth.go: -------------------------------------------------------------------------------- 1 | package rabbitmq 2 | 3 | type ExternalAuthentication struct { 4 | } 5 | 6 | func (auth *ExternalAuthentication) Mechanism() string { 7 | return "EXTERNAL" 8 | } 9 | 10 | func (auth *ExternalAuthentication) Response() string { 11 | return "" 12 | } 13 | -------------------------------------------------------------------------------- /v2/broker/service/service.go: -------------------------------------------------------------------------------- 1 | // Package service provides the broker service client 2 | package service 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/broker" 6 | "github.com/micro/go-micro/v2/broker/service" 7 | "github.com/micro/go-micro/v2/config/cmd" 8 | ) 9 | 10 | func init() { 11 | cmd.DefaultBrokers["service"] = NewBroker 12 | } 13 | 14 | func NewBroker(opts ...broker.Option) broker.Broker { 15 | return service.NewBroker(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v2/broker/stomp/subscriber.go: -------------------------------------------------------------------------------- 1 | package stomp 2 | 3 | import ( 4 | "github.com/go-stomp/stomp" 5 | "github.com/micro/go-micro/v2/broker" 6 | ) 7 | 8 | type subscriber struct { 9 | opts broker.SubscribeOptions 10 | topic string 11 | sub *stomp.Subscription 12 | } 13 | 14 | func (s *subscriber) Options() broker.SubscribeOptions { 15 | return s.opts 16 | } 17 | 18 | func (s *subscriber) Topic() string { 19 | return s.topic 20 | } 21 | 22 | func (s *subscriber) Unsubscribe() error { 23 | return s.sub.Unsubscribe() 24 | } 25 | -------------------------------------------------------------------------------- /v2/client/http/buffer.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type buffer struct { 8 | *bytes.Buffer 9 | } 10 | 11 | func (b *buffer) Close() error { 12 | b.Buffer.Reset() 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /v2/client/http/test/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package test; 4 | 5 | message Message { 6 | int64 seq = 1; 7 | string data = 2; 8 | } 9 | -------------------------------------------------------------------------------- /v2/client/mock/context.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | type responseKey struct{} 8 | 9 | func fromContext(ctx context.Context) (map[string][]MockResponse, bool) { 10 | r, ok := ctx.Value(responseKey{}).(map[string][]MockResponse) 11 | return r, ok 12 | } 13 | 14 | func newContext(ctx context.Context, r map[string][]MockResponse) context.Context { 15 | return context.WithValue(ctx, responseKey{}, r) 16 | } 17 | -------------------------------------------------------------------------------- /v2/client/mock/options.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "github.com/micro/go-micro/v2/client" 5 | ) 6 | 7 | // Response sets the response methods for a service 8 | func Response(service string, response []MockResponse) client.Option { 9 | return func(o *client.Options) { 10 | r, ok := fromContext(o.Context) 11 | if !ok { 12 | r = make(map[string][]MockResponse) 13 | } 14 | r[service] = response 15 | o.Context = newContext(o.Context, r) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /v2/client/selector/label/README.md: -------------------------------------------------------------------------------- 1 | # Label Selector 2 | 3 | The label selecotr is a a priority based label selector. Rather than just returning nodes with specific labels 4 | this selector orders the nodes based on a list of labels. If no labels match all the nodes are still returned. 5 | The priority based label selector is useful for such things as rudimentary AZ based routing where requests made 6 | to other services should remain in the same AZ. 7 | -------------------------------------------------------------------------------- /v2/client/selector/label/options.go: -------------------------------------------------------------------------------- 1 | package label 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/micro/go-micro/v2/client/selector" 7 | ) 8 | 9 | type labelKey struct{} 10 | 11 | type label struct { 12 | key string 13 | val string 14 | } 15 | 16 | // Label used in the priority label list 17 | func Label(k, v string) selector.Option { 18 | return func(o *selector.Options) { 19 | l, ok := o.Context.Value(labelKey{}).([]label) 20 | if !ok { 21 | l = []label{} 22 | } 23 | l = append(l, label{k, v}) 24 | o.Context = context.WithValue(o.Context, labelKey{}, l) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /v2/codec/bsonrpc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/codec/bsonrpc 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/go-micro/go-bson v1.0.0 7 | github.com/micro/go-micro/v2 v2.9.1 8 | ) 9 | 10 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 11 | -------------------------------------------------------------------------------- /v2/codec/jsonrpc2/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/codec/jsonrpc2 2 | 3 | go 1.17 4 | 5 | require github.com/micro/go-micro/v2 v2.9.1 6 | 7 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 8 | -------------------------------------------------------------------------------- /v2/codec/jsonrpc2/license.go: -------------------------------------------------------------------------------- 1 | // Based on powerman/rpc-codec: 2 | // The MIT License (MIT) 3 | // Copyright (c) 2015 Alex Efros 4 | package jsonrpc2 5 | -------------------------------------------------------------------------------- /v2/codec/msgpackrpc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/codec/msgpackrpc 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/micro/go-micro/v2 v2.9.1 7 | github.com/tinylib/msgp v1.1.6 8 | ) 9 | 10 | require github.com/philhofer/fwd v1.1.1 // indirect 11 | 12 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 13 | -------------------------------------------------------------------------------- /v2/config/source/configmap/testdata/config: -------------------------------------------------------------------------------- 1 | host=0.0.0.0 2 | port=1337 -------------------------------------------------------------------------------- /v2/config/source/configmap/testdata/mongodb: -------------------------------------------------------------------------------- 1 | host=127.0.0.1 2 | port=27017 3 | user=user 4 | password=password -------------------------------------------------------------------------------- /v2/config/source/configmap/testdata/redis: -------------------------------------------------------------------------------- 1 | url=redis://127.0.0.1:6379/db01 -------------------------------------------------------------------------------- /v2/config/source/grpc/proto/grpc.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | service Source { 4 | rpc Read(ReadRequest) returns (ReadResponse) {}; 5 | rpc Watch(WatchRequest) returns (stream WatchResponse) {}; 6 | } 7 | 8 | message ChangeSet { 9 | bytes data = 1; 10 | string checksum = 2; 11 | string format = 3; 12 | string source = 4; 13 | int64 timestamp = 5; 14 | } 15 | 16 | message ReadRequest { 17 | string path = 1; 18 | } 19 | 20 | message ReadResponse { 21 | ChangeSet change_set = 1; 22 | } 23 | 24 | message WatchRequest { 25 | string path = 1; 26 | } 27 | 28 | message WatchResponse { 29 | ChangeSet change_set = 1; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /v2/config/source/grpc/util.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | "time" 5 | 6 | proto "github.com/go-micro/plugins/v2/config/source/grpc/proto" 7 | "github.com/micro/go-micro/v2/config/source" 8 | ) 9 | 10 | func toChangeSet(c *proto.ChangeSet) *source.ChangeSet { 11 | return &source.ChangeSet{ 12 | Data: c.Data, 13 | Checksum: c.Checksum, 14 | Format: c.Format, 15 | Timestamp: time.Unix(c.Timestamp, 0), 16 | Source: c.Source, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v2/config/source/mucp/proto/mucp.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | service Source { 4 | rpc Read(ReadRequest) returns (ReadResponse) {}; 5 | rpc Watch(WatchRequest) returns (stream WatchResponse) {}; 6 | } 7 | 8 | message ChangeSet { 9 | bytes data = 1; 10 | string checksum = 2; 11 | string format = 3; 12 | string source = 4; 13 | int64 timestamp = 5; 14 | } 15 | 16 | message ReadRequest { 17 | string path = 1; 18 | } 19 | 20 | message ReadResponse { 21 | ChangeSet change_set = 1; 22 | } 23 | 24 | message WatchRequest { 25 | string path = 1; 26 | } 27 | 28 | message WatchResponse { 29 | ChangeSet change_set = 1; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /v2/config/source/mucp/util.go: -------------------------------------------------------------------------------- 1 | package mucp 2 | 3 | import ( 4 | "time" 5 | 6 | proto "github.com/go-micro/plugins/v2/config/source/mucp/proto" 7 | "github.com/micro/go-micro/v2/config/source" 8 | ) 9 | 10 | func toChangeSet(c *proto.ChangeSet) *source.ChangeSet { 11 | return &source.ChangeSet{ 12 | Data: c.Data, 13 | Checksum: c.Checksum, 14 | Format: c.Format, 15 | Timestamp: time.Unix(c.Timestamp, 0), 16 | Source: c.Source, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v2/config/source/pkger/README.md: -------------------------------------------------------------------------------- 1 | # pkger 2 | 3 | pkger plugin for `go-config` 4 | 5 | ### Prerequisites 6 | 7 | > Install `pkger` cli 8 | 9 | ```bash 10 | go install github.com/markbates/pkger/cmd/pkger 11 | pkger -h 12 | ``` 13 | 14 | ### Packager 15 | 16 | > generating `pkged.go` with all files in `/config` as part of build pipeline 17 | 18 | ```bash 19 | pkger -o srv/greeter -include /config 20 | ``` 21 | 22 | ### Usage 23 | 24 | ```go 25 | if err := config.Load( 26 | pkger.NewSource(pkger.WithPath("/config/config.yaml")), 27 | ); err != nil { 28 | log.Error(err.Error()) 29 | } 30 | ``` 31 | -------------------------------------------------------------------------------- /v2/config/source/pkger/format.go: -------------------------------------------------------------------------------- 1 | package pkger 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/micro/go-micro/v2/config/encoder" 7 | ) 8 | 9 | func format(p string, e encoder.Encoder) string { 10 | parts := strings.Split(p, ".") 11 | if len(parts) > 1 { 12 | return parts[len(parts)-1] 13 | } 14 | return e.String() 15 | } 16 | -------------------------------------------------------------------------------- /v2/config/source/pkger/options.go: -------------------------------------------------------------------------------- 1 | package pkger 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/micro/go-micro/v2/config/source" 7 | ) 8 | 9 | type pkgerPathKey struct{} 10 | 11 | // WithPath sets the path to pkger 12 | func WithPath(p string) source.Option { 13 | return func(o *source.Options) { 14 | if o.Context == nil { 15 | o.Context = context.Background() 16 | } 17 | o.Context = context.WithValue(o.Context, pkgerPathKey{}, p) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /v2/config/source/runtimevar/options.go: -------------------------------------------------------------------------------- 1 | package runtimevar 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/micro/go-micro/v2/config/source" 7 | "gocloud.dev/runtimevar" 8 | ) 9 | 10 | type variableKey struct{} 11 | 12 | // WithVariable sets the runtimevar.Variable. 13 | func WithVariable(v *runtimevar.Variable) source.Option { 14 | return func(o *source.Options) { 15 | if o.Context == nil { 16 | o.Context = context.Background() 17 | } 18 | o.Context = context.WithValue(o.Context, variableKey{}, v) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /v2/config/source/url/format.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | func format(ct string) string { 8 | parts := strings.Split(ct, "/") 9 | if len(parts) <= 1 { 10 | return ct 11 | } 12 | return parts[1] 13 | } 14 | -------------------------------------------------------------------------------- /v2/config/source/url/format_test.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestFormat(t *testing.T) { 8 | testCases := []struct { 9 | contentType string 10 | format string 11 | }{ 12 | {"application/json", "json"}, 13 | {"application/xml", "xml"}, 14 | {"application/json", "json"}, 15 | } 16 | 17 | for _, c := range testCases { 18 | f := format(c.contentType) 19 | if f != c.format { 20 | t.Errorf("failed to format %s: expected %s got %s", c.contentType, c.format, f) 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /v2/config/source/url/options.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/micro/go-micro/v2/config/source" 7 | ) 8 | 9 | type urlKey struct{} 10 | 11 | func WithURL(u string) source.Option { 12 | return func(o *source.Options) { 13 | if o.Context == nil { 14 | o.Context = context.Background() 15 | } 16 | o.Context = context.WithValue(o.Context, urlKey{}, u) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v2/config/source/url/watcher.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/micro/go-micro/v2/config/source" 7 | ) 8 | 9 | type urlWatcher struct { 10 | u *urlSource 11 | exit chan bool 12 | } 13 | 14 | func newWatcher(u *urlSource) (*urlWatcher, error) { 15 | return &urlWatcher{ 16 | u: u, 17 | exit: make(chan bool), 18 | }, nil 19 | } 20 | 21 | func (u *urlWatcher) Next() (*source.ChangeSet, error) { 22 | <-u.exit 23 | return nil, errors.New("url watcher stopped") 24 | } 25 | 26 | func (u *urlWatcher) Stop() error { 27 | select { 28 | case <-u.exit: 29 | default: 30 | } 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /v2/config/source/vault/testdata/vault_init_commands: -------------------------------------------------------------------------------- 1 | vault kv put secret/data/db/auth user=myuser password=mypassword2 host=128.23.33.21 port=3307 -------------------------------------------------------------------------------- /v2/config/source/vault/watcher.go: -------------------------------------------------------------------------------- 1 | package vault 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/hashicorp/vault/api" 7 | "github.com/micro/go-micro/v2/config/source" 8 | ) 9 | 10 | type watcher struct { 11 | c *api.Client 12 | exit chan bool 13 | } 14 | 15 | func newWatcher(c *api.Client) *watcher { 16 | return &watcher{ 17 | c: c, 18 | exit: make(chan bool), 19 | } 20 | } 21 | 22 | func (w *watcher) Next() (*source.ChangeSet, error) { 23 | <-w.exit 24 | return nil, errors.New("url watcher stopped") 25 | } 26 | 27 | func (w *watcher) Stop() error { 28 | select { 29 | case <-w.exit: 30 | default: 31 | } 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /v2/logger/logrus/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/logger/logrus 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/micro/go-micro/v2 v2.9.1 7 | github.com/sirupsen/logrus v1.7.0 8 | ) 9 | 10 | require ( 11 | github.com/google/uuid v1.3.0 // indirect 12 | github.com/stretchr/testify v1.7.0 // indirect 13 | golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect 14 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect 15 | ) 16 | 17 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 18 | -------------------------------------------------------------------------------- /v2/logger/zap/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/logger/zap 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/micro/go-micro/v2 v2.9.1 7 | go.uber.org/zap v1.21.0 8 | ) 9 | 10 | require ( 11 | github.com/google/uuid v1.3.0 // indirect 12 | go.uber.org/atomic v1.7.0 // indirect 13 | go.uber.org/multierr v1.6.0 // indirect 14 | gopkg.in/yaml.v2 v2.4.0 // indirect 15 | ) 16 | 17 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 18 | -------------------------------------------------------------------------------- /v2/logger/zerolog/README.md: -------------------------------------------------------------------------------- 1 | # Zerolog 2 | 3 | [Zerolog](https://github.com/rs/zerolog) logger implementation for __go-micro__ [meta logger](https://github.com/micro/go-micro/tree/master/logger). 4 | 5 | ## Usage 6 | 7 | ```go 8 | func ExampleWithOut() { 9 | logger.DefaultLogger = zerolog.NewLogger(logger.WithOutput(os.Stdout), logger.WithLevel(logger.DebugLevel)) 10 | 11 | logger.Infof(logger.InfoLevel, "testing: %s", "Infof") 12 | 13 | // Output: 14 | // {"level":"info","message":"testing: Infof"} 15 | } 16 | ``` 17 | -------------------------------------------------------------------------------- /v2/logger/zerolog/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/logger/zerolog 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/micro/go-micro/v2 v2.9.1 7 | github.com/rs/zerolog v1.26.1 8 | ) 9 | 10 | require ( 11 | github.com/google/uuid v1.3.0 // indirect 12 | github.com/pkg/errors v0.9.1 // indirect 13 | ) 14 | 15 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 16 | -------------------------------------------------------------------------------- /v2/micro/cors/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/micro/cors 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/micro/cli/v2 v2.1.2 7 | github.com/micro/micro/v2 v2.9.3 8 | github.com/rs/cors v1.8.2 9 | ) 10 | 11 | require ( 12 | github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect 13 | github.com/russross/blackfriday/v2 v2.0.1 // indirect 14 | github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect 15 | ) 16 | 17 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 18 | -------------------------------------------------------------------------------- /v2/micro/disable_rpc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/micro/disable_rpc 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/micro/cli/v2 v2.1.2 7 | github.com/micro/micro/v2 v2.9.3 8 | ) 9 | 10 | require ( 11 | github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect 12 | github.com/russross/blackfriday/v2 v2.0.1 // indirect 13 | github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect 14 | ) 15 | 16 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 17 | -------------------------------------------------------------------------------- /v2/micro/gzip/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/micro/gzip 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/micro/cli/v2 v2.1.2 7 | github.com/micro/micro/v2 v2.9.3 8 | ) 9 | 10 | require ( 11 | github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect 12 | github.com/russross/blackfriday/v2 v2.0.1 // indirect 13 | github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect 14 | ) 15 | 16 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 17 | -------------------------------------------------------------------------------- /v2/micro/header/README.md: -------------------------------------------------------------------------------- 1 | # Header Plugin 2 | 3 | The header plugin allows you to set http headers returned to the client 4 | 5 | ## Usage 6 | 7 | Create a plugin file 8 | 9 | ``` 10 | package main 11 | 12 | import ( 13 | "github.com/go-micro/plugins/v2/micro/header" 14 | "github.com/micro/micro/plugin" 15 | ) 16 | 17 | func init() { 18 | plugin.Register(header.NewPlugin()) 19 | } 20 | ``` 21 | 22 | Build micro binary with the plugin 23 | 24 | It can then be flagged as so 25 | 26 | ``` 27 | micro --header "Access-Control-Allow-Headers=User-Agent,X-Requested-With,If-Modified-Since" api 28 | ``` 29 | -------------------------------------------------------------------------------- /v2/micro/header/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/micro/header 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/micro/cli/v2 v2.1.2 7 | github.com/micro/micro/v2 v2.9.3 8 | ) 9 | 10 | require ( 11 | github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect 12 | github.com/russross/blackfriday/v2 v2.0.1 // indirect 13 | github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect 14 | ) 15 | 16 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 17 | -------------------------------------------------------------------------------- /v2/micro/index/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/micro/index 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/micro/cli/v2 v2.1.2 7 | github.com/micro/micro/v2 v2.9.3 8 | ) 9 | 10 | require ( 11 | github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect 12 | github.com/russross/blackfriday/v2 v2.0.1 // indirect 13 | github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect 14 | ) 15 | 16 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 17 | -------------------------------------------------------------------------------- /v2/micro/ip_allow/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/micro/ip_whitelist 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/micro/cli/v2 v2.1.2 7 | github.com/micro/go-micro/v2 v2.9.1 8 | github.com/micro/micro/v2 v2.9.3 9 | ) 10 | 11 | require ( 12 | github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect 13 | github.com/google/uuid v1.3.0 // indirect 14 | github.com/russross/blackfriday/v2 v2.0.1 // indirect 15 | github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect 16 | ) 17 | 18 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 19 | -------------------------------------------------------------------------------- /v2/micro/metadata/README.md: -------------------------------------------------------------------------------- 1 | # Metadata Plugin 2 | 3 | The metadata plugin lets you set metadata for any micro command or to inject headers into the api, sidecar and web proxy 4 | 5 | ## Usage 6 | 7 | Create a plugin file 8 | 9 | ``` 10 | package main 11 | 12 | import ( 13 | "github.com/go-micro/plugins/v2/micro/metadata" 14 | "github.com/micro/micro/plugin" 15 | ) 16 | 17 | func init() { 18 | plugin.Register(metadata.NewPlugin()) 19 | } 20 | ``` 21 | 22 | Build micro binary with the plugin 23 | 24 | It can then be flagged as so 25 | 26 | ``` 27 | micro --metadata foo=bar --metadata bar=baz query go.micro.srv.greeter Say.Hello '{"name": "john"}' 28 | ``` 29 | -------------------------------------------------------------------------------- /v2/micro/router/options.go: -------------------------------------------------------------------------------- 1 | package router 2 | 3 | import ( 4 | "github.com/micro/go-micro/v2/config" 5 | ) 6 | 7 | type Options struct { 8 | Config config.Config 9 | } 10 | 11 | func Config(c config.Config) Option { 12 | return func(o *Options) { 13 | o.Config = c 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /v2/micro/router/sort.go: -------------------------------------------------------------------------------- 1 | package router 2 | 3 | type sortedRoutes struct { 4 | routes Routes 5 | } 6 | 7 | func (s sortedRoutes) Len() int { 8 | return len(s.routes.Routes) 9 | } 10 | 11 | func (s sortedRoutes) Less(i, j int) bool { 12 | return s.routes.Routes[i].Priority < s.routes.Routes[j].Priority 13 | } 14 | 15 | func (s sortedRoutes) Swap(i, j int) { 16 | s.routes.Routes[i], s.routes.Routes[j] = s.routes.Routes[j], s.routes.Routes[i] 17 | } 18 | -------------------------------------------------------------------------------- /v2/micro/stats_auth/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/micro/stats_auth 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/micro/cli/v2 v2.1.2 7 | github.com/micro/micro/v2 v2.9.3 8 | ) 9 | 10 | require ( 11 | github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect 12 | github.com/russross/blackfriday/v2 v2.0.1 // indirect 13 | github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect 14 | ) 15 | 16 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 17 | -------------------------------------------------------------------------------- /v2/micro/trace/awsxray/awsxray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-micro/plugins/be3f35ce64647f8712cd0578b1e27c879467cb71/v2/micro/trace/awsxray/awsxray.png -------------------------------------------------------------------------------- /v2/micro/trace/awsxray/writer.go: -------------------------------------------------------------------------------- 1 | package awsxray 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | type writer struct { 8 | http.ResponseWriter 9 | status int 10 | } 11 | 12 | func (w *writer) WriteHeader(code int) { 13 | w.ResponseWriter.WriteHeader(code) 14 | w.status = code 15 | } 16 | -------------------------------------------------------------------------------- /v2/micro/trace/uuid/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/micro/trace/uuid 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/google/uuid v1.3.0 7 | github.com/micro/cli/v2 v2.1.2 8 | github.com/micro/micro/v2 v2.9.3 9 | ) 10 | 11 | require ( 12 | github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect 13 | github.com/russross/blackfriday/v2 v2.0.1 // indirect 14 | github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect 15 | ) 16 | 17 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 18 | -------------------------------------------------------------------------------- /v2/registry/cache/cache.go: -------------------------------------------------------------------------------- 1 | // Package cache provides a registry cache 2 | package cache 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/registry" 6 | "github.com/micro/go-micro/v2/registry/cache" 7 | ) 8 | 9 | // New returns a new cache 10 | func New(r registry.Registry, opts ...cache.Option) cache.Cache { 11 | return cache.New(r, opts...) 12 | } 13 | -------------------------------------------------------------------------------- /v2/registry/cache/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/registry/cache 2 | 3 | go 1.17 4 | 5 | require github.com/micro/go-micro/v2 v2.9.1 6 | 7 | require ( 8 | github.com/google/uuid v1.3.0 // indirect 9 | github.com/miekg/dns v1.1.43 // indirect 10 | golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect 11 | golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect 12 | ) 13 | 14 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 15 | -------------------------------------------------------------------------------- /v2/registry/cache/options.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/micro/go-micro/v2/registry/cache" 7 | ) 8 | 9 | // WithTTL sets the cache TTL 10 | func WithTTL(t time.Duration) cache.Option { 11 | return cache.WithTTL(t) 12 | } 13 | -------------------------------------------------------------------------------- /v2/registry/etcd/etcd.go: -------------------------------------------------------------------------------- 1 | // Package etcd provides an etcd v3 service registry 2 | package etcd 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/config/cmd" 6 | "github.com/micro/go-micro/v2/registry" 7 | "github.com/micro/go-micro/v2/registry/etcd" 8 | ) 9 | 10 | func init() { 11 | cmd.DefaultRegistries["etcd"] = etcd.NewRegistry 12 | } 13 | 14 | func NewRegistry(opts ...registry.Option) registry.Registry { 15 | return etcd.NewRegistry(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v2/registry/etcd/options.go: -------------------------------------------------------------------------------- 1 | package etcd 2 | 3 | import ( 4 | "github.com/micro/go-micro/v2/registry" 5 | "github.com/micro/go-micro/v2/registry/etcd" 6 | ) 7 | 8 | // Auth allows you to specify username/password 9 | func Auth(username, password string) registry.Option { 10 | return etcd.Auth(username, password) 11 | } 12 | -------------------------------------------------------------------------------- /v2/registry/etcdv3/etcd.go: -------------------------------------------------------------------------------- 1 | // Package etcd provides an etcd v3 service registry 2 | package etcdv3 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/config/cmd" 6 | "github.com/micro/go-micro/v2/registry" 7 | "github.com/micro/go-micro/v2/registry/etcd" 8 | ) 9 | 10 | func init() { 11 | cmd.DefaultRegistries["etcdv3"] = etcd.NewRegistry 12 | } 13 | 14 | func NewRegistry(opts ...registry.Option) registry.Registry { 15 | return etcd.NewRegistry(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v2/registry/etcdv3/options.go: -------------------------------------------------------------------------------- 1 | package etcdv3 2 | 3 | import ( 4 | "github.com/micro/go-micro/v2/registry" 5 | "github.com/micro/go-micro/v2/registry/etcd" 6 | ) 7 | 8 | // Auth allows you to specify username/password 9 | func Auth(username, password string) registry.Option { 10 | return etcd.Auth(username, password) 11 | } 12 | -------------------------------------------------------------------------------- /v2/registry/gossip/README.md: -------------------------------------------------------------------------------- 1 | # Gossip Registry 2 | 3 | Gossip is a zero dependency registry which uses github.com/hashicorp/memberlist to broadcast registry information 4 | via the SWIM protocol. 5 | 6 | ## Usage 7 | 8 | Start with the registry flag or env var 9 | 10 | ```bash 11 | MICRO_REGISTRY=gossip go run service.go 12 | ``` 13 | 14 | On startup you'll see something like 15 | 16 | ```bash 17 | 2018/12/06 18:17:48 Registry Listening on 192.168.1.65:56390 18 | ``` 19 | 20 | To join this gossip ring set the registry address using flag or env var 21 | 22 | ```bash 23 | MICRO_REGISTRY_ADDRESS=192.168.1.65:56390 24 | ``` 25 | -------------------------------------------------------------------------------- /v2/registry/gossip/proto/gossip.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package gossip; 4 | 5 | // Update is the message broadcast 6 | message Update { 7 | // time to live for entry 8 | uint64 expires = 1; 9 | // type of update 10 | int32 type = 2; 11 | // what action is taken 12 | int32 action = 3; 13 | // any other associated metadata about the data 14 | map metadata = 6; 15 | // the payload data; 16 | bytes data = 7; 17 | } 18 | -------------------------------------------------------------------------------- /v2/registry/kubernetes/client/watch/watch.go: -------------------------------------------------------------------------------- 1 | package watch 2 | 3 | import "encoding/json" 4 | 5 | // Watch ... 6 | type Watch interface { 7 | Stop() 8 | ResultChan() <-chan Event 9 | } 10 | 11 | // EventType defines the possible types of events. 12 | type EventType string 13 | 14 | // EventTypes used 15 | const ( 16 | Added EventType = "ADDED" 17 | Modified EventType = "MODIFIED" 18 | Deleted EventType = "DELETED" 19 | Error EventType = "ERROR" 20 | ) 21 | 22 | // Event represents a single event to a watched resource. 23 | type Event struct { 24 | Type EventType `json:"type"` 25 | Object json.RawMessage `json:"object"` 26 | } 27 | -------------------------------------------------------------------------------- /v2/registry/mdns/mdns.go: -------------------------------------------------------------------------------- 1 | // Package mdns provides a multicast dns registry 2 | package mdns 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/config/cmd" 6 | "github.com/micro/go-micro/v2/registry" 7 | "github.com/micro/go-micro/v2/registry/mdns" 8 | ) 9 | 10 | func init() { 11 | cmd.DefaultRegistries["mdns"] = NewRegistry 12 | } 13 | 14 | // NewRegistry returns a new mdns registry 15 | func NewRegistry(opts ...registry.Option) registry.Registry { 16 | return registry.NewRegistry(opts...) 17 | } 18 | 19 | // Domain sets the mdnsDomain 20 | func Domain(d string) registry.Option { 21 | return mdns.Domain(d) 22 | } 23 | -------------------------------------------------------------------------------- /v2/registry/memory/memory.go: -------------------------------------------------------------------------------- 1 | // Package memory provides an in-memory registry 2 | package memory 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/config/cmd" 6 | "github.com/micro/go-micro/v2/registry" 7 | "github.com/micro/go-micro/v2/registry/memory" 8 | ) 9 | 10 | func init() { 11 | cmd.DefaultRegistries["memory"] = NewRegistry 12 | } 13 | 14 | func NewRegistry(opts ...registry.Option) registry.Registry { 15 | return memory.NewRegistry(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v2/registry/multi/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v2/registry/multi 2 | 3 | go 1.17 4 | 5 | require github.com/micro/go-micro/v2 v2.9.1 6 | 7 | require ( 8 | github.com/google/uuid v1.3.0 // indirect 9 | github.com/miekg/dns v1.1.43 // indirect 10 | golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect 11 | golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect 12 | ) 13 | 14 | replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 15 | -------------------------------------------------------------------------------- /v2/registry/nats/assert_test.go: -------------------------------------------------------------------------------- 1 | package nats_test 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func assertNoError(tb testing.TB, actual error) { 9 | if actual != nil { 10 | tb.Errorf("expected no error, got %v", actual) 11 | } 12 | } 13 | 14 | func assertEqual(tb testing.TB, expected, actual interface{}) { 15 | if !reflect.DeepEqual(expected, actual) { 16 | tb.Errorf("expected %v, got %v", expected, actual) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v2/registry/proxy/README.md: -------------------------------------------------------------------------------- 1 | # Proxy Registry 2 | 3 | This is a registry plugin for the micro [proxy](https://micro.mu/docs/proxy.html) 4 | 5 | ## Usage 6 | 7 | Here's a simple usage guide 8 | 9 | ### Run Proxy 10 | 11 | ``` 12 | # download 13 | go get github.com/micro/micro 14 | 15 | # run 16 | micro proxy 17 | ``` 18 | 19 | ### Import and Flag plugin 20 | 21 | ```go 22 | import _ "github.com/go-micro/plugins/v2/registry/proxy" 23 | ``` 24 | 25 | ``` 26 | go run main.go --registry=proxy 27 | ``` 28 | -------------------------------------------------------------------------------- /v2/registry/service/service.go: -------------------------------------------------------------------------------- 1 | // Package service uses the registry service 2 | package service 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/config/cmd" 6 | "github.com/micro/go-micro/v2/registry" 7 | "github.com/micro/go-micro/v2/registry/service" 8 | ) 9 | 10 | func init() { 11 | cmd.DefaultRegistries["service"] = NewRegistry 12 | } 13 | 14 | // NewRegistry returns a new registry service client 15 | func NewRegistry(opts ...registry.Option) registry.Registry { 16 | return service.NewRegistry(opts...) 17 | } 18 | -------------------------------------------------------------------------------- /v2/server/http/buffer.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type buffer struct { 8 | *bytes.Buffer 9 | } 10 | 11 | func (b *buffer) Close() error { 12 | b.Buffer.Reset() 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /v2/server/http/context.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/micro/go-micro/v2/server" 7 | ) 8 | 9 | func setServerOption(k, v interface{}) server.Option { 10 | return func(o *server.Options) { 11 | if o.Context == nil { 12 | o.Context = context.Background() 13 | } 14 | o.Context = context.WithValue(o.Context, k, v) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /v2/server/http/handler.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "github.com/micro/go-micro/v2/registry" 5 | "github.com/micro/go-micro/v2/server" 6 | ) 7 | 8 | type httpHandler struct { 9 | opts server.HandlerOptions 10 | eps []*registry.Endpoint 11 | hd interface{} 12 | } 13 | 14 | func (h *httpHandler) Name() string { 15 | return "handler" 16 | } 17 | 18 | func (h *httpHandler) Handler() interface{} { 19 | return h.hd 20 | } 21 | 22 | func (h *httpHandler) Endpoints() []*registry.Endpoint { 23 | return h.eps 24 | } 25 | 26 | func (h *httpHandler) Options() server.HandlerOptions { 27 | return h.opts 28 | } 29 | -------------------------------------------------------------------------------- /v2/transport/grpc/grpc.go: -------------------------------------------------------------------------------- 1 | // Package grpc provides a grpc transport 2 | package grpc 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/config/cmd" 6 | "github.com/micro/go-micro/v2/transport" 7 | "github.com/micro/go-micro/v2/transport/grpc" 8 | ) 9 | 10 | func init() { 11 | cmd.DefaultTransports["grpc"] = NewTransport 12 | } 13 | 14 | func NewTransport(opts ...transport.Option) transport.Transport { 15 | return grpc.NewTransport(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v2/transport/http/http.go: -------------------------------------------------------------------------------- 1 | // Package http returns a http2 transport using net/http 2 | package http 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/config/cmd" 6 | "github.com/micro/go-micro/v2/transport" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultTransports["http"] = NewTransport 11 | } 12 | 13 | // NewTransport returns a new http transport using net/http and supporting http2 14 | func NewTransport(opts ...transport.Option) transport.Transport { 15 | return transport.NewTransport(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v2/transport/http/options.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/micro/go-micro/v2/transport" 7 | thttp "github.com/micro/go-micro/v2/transport/http" 8 | ) 9 | 10 | // Handle registers the handler for the given pattern. 11 | func Handle(pattern string, handler http.Handler) transport.Option { 12 | return thttp.Handle(pattern, handler) 13 | } 14 | -------------------------------------------------------------------------------- /v2/transport/memory/memory.go: -------------------------------------------------------------------------------- 1 | // Package memory is an in-memory transport 2 | package memory 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/config/cmd" 6 | "github.com/micro/go-micro/v2/transport" 7 | "github.com/micro/go-micro/v2/transport/memory" 8 | ) 9 | 10 | func init() { 11 | cmd.DefaultTransports["memory"] = NewTransport 12 | } 13 | 14 | func NewTransport(opts ...transport.Option) transport.Transport { 15 | return memory.NewTransport(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v2/transport/nats/options.go: -------------------------------------------------------------------------------- 1 | package nats 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/micro/go-micro/v2/transport" 7 | "github.com/nats-io/nats.go" 8 | ) 9 | 10 | type optionsKey struct{} 11 | 12 | // Options allow to inject a nats.Options struct for configuring 13 | // the nats connection 14 | func Options(nopts nats.Options) transport.Option { 15 | return func(o *transport.Options) { 16 | if o.Context == nil { 17 | o.Context = context.Background() 18 | } 19 | o.Context = context.WithValue(o.Context, optionsKey{}, nopts) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /v2/transport/quic/quic.go: -------------------------------------------------------------------------------- 1 | // Package quic provides a QUIC based transport 2 | package quic 3 | 4 | import ( 5 | "github.com/micro/go-micro/v2/config/cmd" 6 | "github.com/micro/go-micro/v2/transport" 7 | "github.com/micro/go-micro/v2/transport/quic" 8 | ) 9 | 10 | func init() { 11 | cmd.DefaultTransports["quic"] = NewTransport 12 | } 13 | 14 | func NewTransport(opts ...transport.Option) transport.Transport { 15 | return quic.NewTransport(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v2/transport/utp/README.md: -------------------------------------------------------------------------------- 1 | # uTP Transport 2 | 3 | The uTP transport is a go-micro transport which makes use of github.com/anacrolix/utp 4 | 5 | uTP is the [Micro Transport Protocol](https://en.wikipedia.org/wiki/Micro_Transport_Protocol) an 6 | open UDP variant of the BitTorrent protocol. 7 | 8 | 9 | The uTP transport in combination with STUN allows for peer to peer communication. 10 | -------------------------------------------------------------------------------- /v2/wrapper/select/roundrobin/README.md: -------------------------------------------------------------------------------- 1 | # Round Robin Wrapper 2 | 3 | The round robin wrapper is a stateful client wrapper which gives you a true round robin strategy for the selector 4 | 5 | ## Usage 6 | 7 | Pass in the wrapper when you create your service 8 | 9 | ``` 10 | wrapper := roundrobin.NewClientWrapper() 11 | 12 | service := micro.NewService( 13 | micro.Name("foo"), 14 | micro.WrapClient(wrapper), 15 | ) 16 | ``` 17 | -------------------------------------------------------------------------------- /v2/wrapper/select/version/README.md: -------------------------------------------------------------------------------- 1 | # Version Wrapper 2 | 3 | The version wrapper is a stateful client wrapper which gives you a ability to select only latest version services. That suitable for easy upgrade running services without downtime. 4 | 5 | ## Usage 6 | 7 | Pass in the wrapper when you create your service 8 | 9 | ``` 10 | wrapper := version.NewClientWrapper() 11 | 12 | service := micro.NewService( 13 | micro.Name("foo"), 14 | micro.WrapClient(wrapper), 15 | ) 16 | ``` 17 | -------------------------------------------------------------------------------- /v2/wrapper/trace/awsxray/awsxray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-micro/plugins/be3f35ce64647f8712cd0578b1e27c879467cb71/v2/wrapper/trace/awsxray/awsxray.png -------------------------------------------------------------------------------- /v2/wrapper/trace/datadog/ext.go: -------------------------------------------------------------------------------- 1 | package datadog 2 | 3 | const ( 4 | // tagendpoint = "micro.endpoint" 5 | // tagservice = "micro.service" 6 | // tagMethod = "micro.method" 7 | tagStatus = "micro.status" 8 | tagRole = "micro.role" 9 | tagID = "micro.id" 10 | tagVersion = "micro.version" 11 | ) 12 | -------------------------------------------------------------------------------- /v2/wrapper/trace/datadog/stats.go: -------------------------------------------------------------------------------- 1 | package datadog 2 | 3 | // TODO: add statd 4 | // https://github.com/DataDog/datadog-go/tree/master/statsd 5 | 6 | // StatsProfile groups metrics-related data. 7 | type StatsProfile struct { 8 | Role string 9 | } 10 | 11 | var ( 12 | // ClientProfile is used for RPC clients. 13 | ClientProfile = &StatsProfile{ 14 | Role: "micro.client", 15 | } 16 | 17 | // ServerProfile is used for RPC servers. 18 | ServerProfile = &StatsProfile{ 19 | Role: "micro.server", 20 | } 21 | ) 22 | -------------------------------------------------------------------------------- /v2/wrapper/trace/datadog/status.go: -------------------------------------------------------------------------------- 1 | package datadog 2 | 3 | import ( 4 | "google.golang.org/grpc/codes" 5 | ) 6 | 7 | var microCodeToStatusCode = map[int32]codes.Code{ 8 | 400: codes.InvalidArgument, 9 | 401: codes.Unauthenticated, 10 | 403: codes.PermissionDenied, 11 | 404: codes.NotFound, 12 | 409: codes.Aborted, 13 | 500: codes.Internal, 14 | } 15 | -------------------------------------------------------------------------------- /v3/acme/certmagic/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/acme/certmagic 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/caddyserver/certmagic v0.11.2 8 | ) 9 | -------------------------------------------------------------------------------- /v3/auth/jwt/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/auth/jwt 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/dgrijalva/jwt-go v3.2.0+incompatible 8 | ) 9 | -------------------------------------------------------------------------------- /v3/broker/gocloud/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/gocloud 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/streadway/amqp v1.0.0 8 | gocloud.dev v0.17.0 9 | gocloud.dev/pubsub/rabbitpubsub v0.17.0 10 | ) 11 | -------------------------------------------------------------------------------- /v3/broker/googlepubsub/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/googlepubsub 2 | 3 | go 1.16 4 | 5 | require ( 6 | cloud.google.com/go/pubsub v1.12.0 7 | github.com/asim/go-micro/v3 v3.7.1 8 | github.com/google/uuid v1.2.0 9 | google.golang.org/api v0.49.0 10 | google.golang.org/grpc v1.38.0 11 | ) 12 | -------------------------------------------------------------------------------- /v3/broker/grpc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/grpc 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/golang/protobuf v1.5.2 8 | github.com/google/uuid v1.2.0 9 | golang.org/x/net v0.0.0-20210510120150-4163338589ed 10 | google.golang.org/grpc v1.38.0 11 | ) 12 | -------------------------------------------------------------------------------- /v3/broker/grpc/proto/broker.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package broker; 4 | 5 | service Broker { 6 | rpc Publish(Message) returns (Empty) {} 7 | } 8 | 9 | message Message { 10 | string topic = 1; 11 | string id = 2; 12 | map header = 3; 13 | bytes body = 4; 14 | } 15 | 16 | message Empty {} 17 | -------------------------------------------------------------------------------- /v3/broker/http/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/http 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/google/uuid v1.2.0 8 | golang.org/x/net v0.0.0-20210510120150-4163338589ed 9 | ) 10 | -------------------------------------------------------------------------------- /v3/broker/kafka/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/kafka 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/Shopify/sarama v1.29.1 7 | github.com/asim/go-micro/v3 v3.7.1 8 | github.com/google/uuid v1.2.0 9 | ) 10 | -------------------------------------------------------------------------------- /v3/broker/memory/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/memory 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/google/uuid v1.2.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/broker/mqtt/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/mqtt 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/eclipse/paho.mqtt.golang v1.3.5 8 | ) 9 | -------------------------------------------------------------------------------- /v3/broker/nats/context.go: -------------------------------------------------------------------------------- 1 | package nats 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/asim/go-micro/v3/broker" 7 | ) 8 | 9 | // setBrokerOption returns a function to setup a context with given value 10 | func setBrokerOption(k, v interface{}) broker.Option { 11 | return func(o *broker.Options) { 12 | if o.Context == nil { 13 | o.Context = context.Background() 14 | } 15 | o.Context = context.WithValue(o.Context, k, v) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /v3/broker/nats/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/nats 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/nats-io/nats-server/v2 v2.3.1 // indirect 8 | github.com/nats-io/nats.go v1.11.1-0.20210623165838-4b75fc59ae30 9 | ) 10 | -------------------------------------------------------------------------------- /v3/broker/nats/options.go: -------------------------------------------------------------------------------- 1 | package nats 2 | 3 | import ( 4 | "github.com/asim/go-micro/v3/broker" 5 | nats "github.com/nats-io/nats.go" 6 | ) 7 | 8 | type optionsKey struct{} 9 | type drainConnectionKey struct{} 10 | 11 | // Options accepts nats.Options 12 | func Options(opts nats.Options) broker.Option { 13 | return setBrokerOption(optionsKey{}, opts) 14 | } 15 | 16 | // DrainConnection will drain subscription on close 17 | func DrainConnection() broker.Option { 18 | return setBrokerOption(drainConnectionKey{}, struct{}{}) 19 | } 20 | -------------------------------------------------------------------------------- /v3/broker/nsq/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/nsq 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/google/uuid v1.2.0 8 | github.com/nsqio/go-nsq v1.0.8 9 | ) 10 | -------------------------------------------------------------------------------- /v3/broker/proxy/README.md: -------------------------------------------------------------------------------- 1 | # Proxy Broker 2 | 3 | This is a broker plugin for the micro [proxy](https://micro.mu/docs/proxy.html) 4 | 5 | ## Usage 6 | 7 | Here's a simple usage guide 8 | 9 | ### Run Proxy 10 | 11 | ``` 12 | # install micro 13 | go get github.com/micro/micro 14 | 15 | # run proxy 16 | micro proxy 17 | ``` 18 | 19 | ### Import and Flag plugin 20 | 21 | ``` 22 | import _ "github.com/go-micro/plugins/v3/broker/proxy" 23 | ``` 24 | 25 | ``` 26 | go run main.go --broker=proxy 27 | ``` 28 | -------------------------------------------------------------------------------- /v3/broker/proxy/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/proxy 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/gorilla/websocket v1.4.2 8 | ) 9 | -------------------------------------------------------------------------------- /v3/broker/proxy/publication.go: -------------------------------------------------------------------------------- 1 | package proxy 2 | 3 | import ( 4 | "github.com/asim/go-micro/v3/broker" 5 | ) 6 | 7 | type publication struct { 8 | topic string 9 | message *broker.Message 10 | err error 11 | } 12 | 13 | func (p *publication) Topic() string { 14 | return p.topic 15 | } 16 | 17 | func (p *publication) Message() *broker.Message { 18 | return p.message 19 | } 20 | 21 | func (p *publication) Ack() error { 22 | return nil 23 | } 24 | 25 | func (p *publication) Error() error { 26 | return p.err 27 | } 28 | -------------------------------------------------------------------------------- /v3/broker/rabbitmq/auth.go: -------------------------------------------------------------------------------- 1 | package rabbitmq 2 | 3 | type ExternalAuthentication struct { 4 | } 5 | 6 | func (auth *ExternalAuthentication) Mechanism() string { 7 | return "EXTERNAL" 8 | } 9 | 10 | func (auth *ExternalAuthentication) Response() string { 11 | return "" 12 | } 13 | -------------------------------------------------------------------------------- /v3/broker/rabbitmq/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/rabbitmq 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/google/uuid v1.2.0 8 | github.com/streadway/amqp v1.0.0 9 | ) 10 | -------------------------------------------------------------------------------- /v3/broker/redis/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/redis 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/gomodule/redigo v1.8.5 8 | ) 9 | -------------------------------------------------------------------------------- /v3/broker/segmentio/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/segmentio 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/go-micro/plugins/v3/broker/kafka v1.0.0 8 | github.com/go-micro/plugins/v3/codec/segmentio v1.0.0 9 | github.com/google/uuid v1.2.0 10 | github.com/segmentio/kafka-go v0.4.16 11 | ) 12 | 13 | replace ( 14 | github.com/go-micro/plugins/v3/broker/kafka => ../kafka 15 | github.com/go-micro/plugins/v3/codec/segmentio => ../../codec/segmentio 16 | ) 17 | -------------------------------------------------------------------------------- /v3/broker/snssqs/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/snssqs 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/aws/aws-sdk-go v1.38.69 8 | golang.org/x/text v0.3.6 9 | ) 10 | -------------------------------------------------------------------------------- /v3/broker/sqs/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/sqs 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/aws/aws-sdk-go v1.38.69 8 | ) 9 | -------------------------------------------------------------------------------- /v3/broker/stan/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/stan 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/google/uuid v1.2.0 8 | github.com/nats-io/nats-server/v2 v2.3.0 // indirect 9 | github.com/nats-io/nats-streaming-server v0.22.0 // indirect 10 | github.com/nats-io/stan.go v0.9.0 11 | ) 12 | -------------------------------------------------------------------------------- /v3/broker/stomp/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/broker/stomp 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/go-stomp/stomp/v3 v3.0.1 8 | ) 9 | -------------------------------------------------------------------------------- /v3/broker/stomp/subscriber.go: -------------------------------------------------------------------------------- 1 | package stomp 2 | 3 | import ( 4 | "github.com/asim/go-micro/v3/broker" 5 | "github.com/go-stomp/stomp/v3" 6 | ) 7 | 8 | type subscriber struct { 9 | opts broker.SubscribeOptions 10 | topic string 11 | sub *stomp.Subscription 12 | } 13 | 14 | func (s *subscriber) Options() broker.SubscribeOptions { 15 | return s.opts 16 | } 17 | 18 | func (s *subscriber) Topic() string { 19 | return s.topic 20 | } 21 | 22 | func (s *subscriber) Unsubscribe() error { 23 | return s.sub.Unsubscribe() 24 | } 25 | -------------------------------------------------------------------------------- /v3/client/grpc/README.md: -------------------------------------------------------------------------------- 1 | # GRPC Client 2 | 3 | The grpc client is a [micro.Client](https://godoc.org/github.com/micro/go-micro/client#Client) compatible client. 4 | 5 | ## Overview 6 | 7 | The client makes use of the [google.golang.org/grpc](google.golang.org/grpc) framework for the underlying communication mechanism. 8 | 9 | ## Usage 10 | 11 | Specify the client to your micro service 12 | 13 | ```go 14 | import ( 15 | "github.com/micro/go-micro" 16 | "github.com/micro/go-plugins/client/grpc" 17 | ) 18 | 19 | func main() { 20 | service := micro.NewService( 21 | micro.Name("greeter"), 22 | micro.Client(grpc.NewClient()), 23 | ) 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /v3/client/grpc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/client/grpc 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/golang/protobuf v1.5.2 8 | github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c 9 | google.golang.org/grpc v1.38.0 10 | google.golang.org/grpc/examples v0.0.0-20210902184326-c93e472777b9 11 | ) 12 | -------------------------------------------------------------------------------- /v3/client/http/buffer.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type buffer struct { 8 | *bytes.Buffer 9 | } 10 | 11 | func (b *buffer) Close() error { 12 | b.Buffer.Reset() 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /v3/client/http/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/client/http 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/golang/protobuf v1.5.2 8 | ) 9 | -------------------------------------------------------------------------------- /v3/client/http/test/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package test; 4 | 5 | message Message { 6 | int64 seq = 1; 7 | string data = 2; 8 | } 9 | -------------------------------------------------------------------------------- /v3/client/mock/context.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "context" 5 | ) 6 | 7 | type responseKey struct{} 8 | 9 | func fromContext(ctx context.Context) (map[string][]MockResponse, bool) { 10 | r, ok := ctx.Value(responseKey{}).(map[string][]MockResponse) 11 | return r, ok 12 | } 13 | 14 | func newContext(ctx context.Context, r map[string][]MockResponse) context.Context { 15 | return context.WithValue(ctx, responseKey{}, r) 16 | } 17 | -------------------------------------------------------------------------------- /v3/client/mock/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/client/mock 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/client/mock/options.go: -------------------------------------------------------------------------------- 1 | package mock 2 | 3 | import ( 4 | "github.com/asim/go-micro/v3/client" 5 | ) 6 | 7 | // Response sets the response methods for a service 8 | func Response(service string, response []MockResponse) client.Option { 9 | return func(o *client.Options) { 10 | r, ok := fromContext(o.Context) 11 | if !ok { 12 | r = make(map[string][]MockResponse) 13 | } 14 | r[service] = response 15 | o.Context = newContext(o.Context, r) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /v3/client/mucp/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/client/mucp 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/client/mucp/mucp.go: -------------------------------------------------------------------------------- 1 | // Package mucp provides an mucp client 2 | package mucp 3 | 4 | import ( 5 | "github.com/asim/go-micro/v3/client" 6 | "github.com/asim/go-micro/v3/cmd" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultClients["mucp"] = NewClient 11 | } 12 | 13 | // NewClient returns a new micro client interface 14 | func NewClient(opts ...client.Option) client.Client { 15 | return client.NewClient(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v3/codec/bsonrpc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/codec/bsonrpc 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/go-micro/go-bson v1.0.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/codec/json-iterator/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/codec/json-iterator 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/golang/protobuf v1.5.2 8 | github.com/json-iterator/go v1.1.11 9 | github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c 10 | ) 11 | -------------------------------------------------------------------------------- /v3/codec/jsonrpc2/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/codec/jsonrpc2 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/codec/jsonrpc2/license.go: -------------------------------------------------------------------------------- 1 | // Based on powerman/rpc-codec: 2 | // The MIT License (MIT) 3 | // Copyright (c) 2015 Alex Efros 4 | package jsonrpc2 5 | -------------------------------------------------------------------------------- /v3/codec/msgpackrpc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/codec/msgpackrpc 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/tinylib/msgp v1.1.6 8 | ) 9 | -------------------------------------------------------------------------------- /v3/codec/segmentio/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/codec/segmentio 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/golang/protobuf v1.5.2 8 | github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c 9 | github.com/segmentio/encoding v0.1.12 10 | ) 11 | -------------------------------------------------------------------------------- /v3/config/encoder/cue/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/encoder/cue 2 | 3 | go 1.16 4 | 5 | require ( 6 | cuelang.org/go v0.0.15 7 | github.com/asim/go-micro/v3 v3.7.1 8 | github.com/ghodss/yaml v1.0.0 9 | github.com/stretchr/testify v1.7.0 10 | ) 11 | -------------------------------------------------------------------------------- /v3/config/encoder/hcl/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/encoder/hcl 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/hashicorp/hcl v1.0.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/config/encoder/hcl/hcl.go: -------------------------------------------------------------------------------- 1 | package hcl 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/asim/go-micro/v3/config/encoder" 7 | "github.com/hashicorp/hcl" 8 | ) 9 | 10 | type hclEncoder struct{} 11 | 12 | func (h hclEncoder) Encode(v interface{}) ([]byte, error) { 13 | return json.Marshal(v) 14 | } 15 | 16 | func (h hclEncoder) Decode(d []byte, v interface{}) error { 17 | return hcl.Unmarshal(d, v) 18 | } 19 | 20 | func (h hclEncoder) String() string { 21 | return "hcl" 22 | } 23 | 24 | func NewEncoder() encoder.Encoder { 25 | return hclEncoder{} 26 | } 27 | -------------------------------------------------------------------------------- /v3/config/encoder/toml/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/encoder/toml 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/BurntSushi/toml v0.3.1 7 | github.com/asim/go-micro/v3 v3.7.1 8 | ) 9 | -------------------------------------------------------------------------------- /v3/config/encoder/xml/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/encoder/xml 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/config/encoder/xml/xml.go: -------------------------------------------------------------------------------- 1 | package xml 2 | 3 | import ( 4 | "encoding/xml" 5 | 6 | "github.com/asim/go-micro/v3/config/encoder" 7 | ) 8 | 9 | type xmlEncoder struct{} 10 | 11 | func (x xmlEncoder) Encode(v interface{}) ([]byte, error) { 12 | return xml.Marshal(v) 13 | } 14 | 15 | func (x xmlEncoder) Decode(d []byte, v interface{}) error { 16 | return xml.Unmarshal(d, v) 17 | } 18 | 19 | func (x xmlEncoder) String() string { 20 | return "xml" 21 | } 22 | 23 | func NewEncoder() encoder.Encoder { 24 | return xmlEncoder{} 25 | } 26 | -------------------------------------------------------------------------------- /v3/config/encoder/yaml/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/encoder/yaml 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/ghodss/yaml v1.0.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/config/encoder/yaml/yaml.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | import ( 4 | "github.com/asim/go-micro/v3/config/encoder" 5 | "github.com/ghodss/yaml" 6 | ) 7 | 8 | type yamlEncoder struct{} 9 | 10 | func (y yamlEncoder) Encode(v interface{}) ([]byte, error) { 11 | return yaml.Marshal(v) 12 | } 13 | 14 | func (y yamlEncoder) Decode(d []byte, v interface{}) error { 15 | return yaml.Unmarshal(d, v) 16 | } 17 | 18 | func (y yamlEncoder) String() string { 19 | return "yaml" 20 | } 21 | 22 | func NewEncoder() encoder.Encoder { 23 | return yamlEncoder{} 24 | } 25 | -------------------------------------------------------------------------------- /v3/config/source/configmap/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/source/configmap 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | k8s.io/api v0.23.5 8 | k8s.io/apimachinery v0.23.5 9 | k8s.io/client-go v0.23.5 10 | ) 11 | -------------------------------------------------------------------------------- /v3/config/source/configmap/testdata/config: -------------------------------------------------------------------------------- 1 | host=0.0.0.0 2 | port=1337 -------------------------------------------------------------------------------- /v3/config/source/configmap/testdata/mongodb: -------------------------------------------------------------------------------- 1 | host=127.0.0.1 2 | port=27017 3 | user=user 4 | password=password -------------------------------------------------------------------------------- /v3/config/source/configmap/testdata/redis: -------------------------------------------------------------------------------- 1 | url=redis://127.0.0.1:6379/db01 -------------------------------------------------------------------------------- /v3/config/source/consul/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/source/consul 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/hashicorp/consul/api v1.9.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/config/source/etcd/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/source/etcd 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | go.etcd.io/etcd/api/v3 v3.5.0 8 | go.etcd.io/etcd/client/v3 v3.5.0 9 | ) 10 | -------------------------------------------------------------------------------- /v3/config/source/grpc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/source/grpc 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/golang/protobuf v1.5.2 8 | golang.org/x/net v0.0.0-20210614182718-04defd469f4e 9 | google.golang.org/grpc v1.38.0 10 | ) 11 | -------------------------------------------------------------------------------- /v3/config/source/grpc/proto/grpc.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | service Source { 4 | rpc Read(ReadRequest) returns (ReadResponse) {}; 5 | rpc Watch(WatchRequest) returns (stream WatchResponse) {}; 6 | } 7 | 8 | message ChangeSet { 9 | bytes data = 1; 10 | string checksum = 2; 11 | string format = 3; 12 | string source = 4; 13 | int64 timestamp = 5; 14 | } 15 | 16 | message ReadRequest { 17 | string path = 1; 18 | } 19 | 20 | message ReadResponse { 21 | ChangeSet change_set = 1; 22 | } 23 | 24 | message WatchRequest { 25 | string path = 1; 26 | } 27 | 28 | message WatchResponse { 29 | ChangeSet change_set = 1; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /v3/config/source/grpc/util.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/asim/go-micro/v3/config/source" 7 | proto "github.com/go-micro/plugins/v3/config/source/grpc/proto" 8 | ) 9 | 10 | func toChangeSet(c *proto.ChangeSet) *source.ChangeSet { 11 | return &source.ChangeSet{ 12 | Data: c.Data, 13 | Checksum: c.Checksum, 14 | Format: c.Format, 15 | Timestamp: time.Unix(c.Timestamp, 0), 16 | Source: c.Source, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v3/config/source/mucp/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/source/mucp 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/golang/protobuf v1.5.2 8 | ) 9 | -------------------------------------------------------------------------------- /v3/config/source/mucp/proto/mucp.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | service Source { 4 | rpc Read(ReadRequest) returns (ReadResponse) {}; 5 | rpc Watch(WatchRequest) returns (stream WatchResponse) {}; 6 | } 7 | 8 | message ChangeSet { 9 | bytes data = 1; 10 | string checksum = 2; 11 | string format = 3; 12 | string source = 4; 13 | int64 timestamp = 5; 14 | } 15 | 16 | message ReadRequest { 17 | string path = 1; 18 | } 19 | 20 | message ReadResponse { 21 | ChangeSet change_set = 1; 22 | } 23 | 24 | message WatchRequest { 25 | string path = 1; 26 | } 27 | 28 | message WatchResponse { 29 | ChangeSet change_set = 1; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /v3/config/source/mucp/util.go: -------------------------------------------------------------------------------- 1 | package mucp 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/asim/go-micro/v3/config/source" 7 | proto "github.com/go-micro/plugins/v3/config/source/mucp/proto" 8 | ) 9 | 10 | func toChangeSet(c *proto.ChangeSet) *source.ChangeSet { 11 | return &source.ChangeSet{ 12 | Data: c.Data, 13 | Checksum: c.Checksum, 14 | Format: c.Format, 15 | Timestamp: time.Unix(c.Timestamp, 0), 16 | Source: c.Source, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v3/config/source/nacos/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/source/nacos 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/nacos-group/nacos-sdk-go/v2 v2.0.0-Alpha.1 8 | ) 9 | -------------------------------------------------------------------------------- /v3/config/source/pkger/README.md: -------------------------------------------------------------------------------- 1 | # pkger 2 | 3 | pkger plugin for `go-config` 4 | 5 | ### Prerequisites 6 | 7 | > Install `pkger` cli 8 | 9 | ```bash 10 | go install github.com/markbates/pkger/cmd/pkger 11 | pkger -h 12 | ``` 13 | 14 | ### Packager 15 | 16 | > generating `pkged.go` with all files in `/config` as part of build pipeline 17 | 18 | ```bash 19 | pkger -o srv/greeter -include /config 20 | ``` 21 | 22 | ### Usage 23 | 24 | ```go 25 | if err := config.Load( 26 | pkger.NewSource(pkger.WithPath("/config/config.yaml")), 27 | ); err != nil { 28 | log.Fatal(err.Error()) 29 | } 30 | ``` 31 | -------------------------------------------------------------------------------- /v3/config/source/pkger/format.go: -------------------------------------------------------------------------------- 1 | package pkger 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/asim/go-micro/v3/config/encoder" 7 | ) 8 | 9 | func format(p string, e encoder.Encoder) string { 10 | parts := strings.Split(p, ".") 11 | if len(parts) > 1 { 12 | return parts[len(parts)-1] 13 | } 14 | return e.String() 15 | } 16 | -------------------------------------------------------------------------------- /v3/config/source/pkger/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/source/pkger 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/markbates/pkger v0.17.1 8 | ) 9 | -------------------------------------------------------------------------------- /v3/config/source/pkger/options.go: -------------------------------------------------------------------------------- 1 | package pkger 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/asim/go-micro/v3/config/source" 7 | ) 8 | 9 | type pkgerPathKey struct{} 10 | 11 | // WithPath sets the path to pkger 12 | func WithPath(p string) source.Option { 13 | return func(o *source.Options) { 14 | if o.Context == nil { 15 | o.Context = context.Background() 16 | } 17 | o.Context = context.WithValue(o.Context, pkgerPathKey{}, p) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /v3/config/source/runtimevar/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/source/runtimevar 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | gocloud.dev v0.17.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/config/source/runtimevar/options.go: -------------------------------------------------------------------------------- 1 | package runtimevar 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/asim/go-micro/v3/config/source" 7 | "gocloud.dev/runtimevar" 8 | ) 9 | 10 | type variableKey struct{} 11 | 12 | // WithVariable sets the runtimevar.Variable. 13 | func WithVariable(v *runtimevar.Variable) source.Option { 14 | return func(o *source.Options) { 15 | if o.Context == nil { 16 | o.Context = context.Background() 17 | } 18 | o.Context = context.WithValue(o.Context, variableKey{}, v) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /v3/config/source/url/format.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | func format(ct string) string { 8 | parts := strings.Split(ct, "/") 9 | if len(parts) <= 1 { 10 | return ct 11 | } 12 | return parts[1] 13 | } 14 | -------------------------------------------------------------------------------- /v3/config/source/url/format_test.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestFormat(t *testing.T) { 8 | testCases := []struct { 9 | contentType string 10 | format string 11 | }{ 12 | {"application/json", "json"}, 13 | {"application/xml", "xml"}, 14 | {"application/json", "json"}, 15 | } 16 | 17 | for _, c := range testCases { 18 | f := format(c.contentType) 19 | if f != c.format { 20 | t.Fatalf("failed to format %s: expected %s got %s", c.contentType, c.format, f) 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /v3/config/source/url/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/source/url 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/config/source/url/options.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/asim/go-micro/v3/config/source" 7 | ) 8 | 9 | type urlKey struct{} 10 | 11 | func WithURL(u string) source.Option { 12 | return func(o *source.Options) { 13 | if o.Context == nil { 14 | o.Context = context.Background() 15 | } 16 | o.Context = context.WithValue(o.Context, urlKey{}, u) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v3/config/source/url/watcher.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/asim/go-micro/v3/config/source" 7 | ) 8 | 9 | type urlWatcher struct { 10 | u *urlSource 11 | exit chan bool 12 | } 13 | 14 | func newWatcher(u *urlSource) (*urlWatcher, error) { 15 | return &urlWatcher{ 16 | u: u, 17 | exit: make(chan bool), 18 | }, nil 19 | } 20 | 21 | func (u *urlWatcher) Next() (*source.ChangeSet, error) { 22 | <-u.exit 23 | return nil, errors.New("url watcher stopped") 24 | } 25 | 26 | func (u *urlWatcher) Stop() error { 27 | select { 28 | case <-u.exit: 29 | default: 30 | } 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /v3/config/source/vault/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/config/source/vault 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/hashicorp/vault/api v1.0.4 8 | ) 9 | -------------------------------------------------------------------------------- /v3/config/source/vault/testdata/vault_init_commands: -------------------------------------------------------------------------------- 1 | vault kv put secret/data/db/auth user=myuser password=mypassword2 host=128.23.33.21 port=3307 -------------------------------------------------------------------------------- /v3/config/source/vault/watcher.go: -------------------------------------------------------------------------------- 1 | package vault 2 | 3 | import ( 4 | "errors" 5 | "github.com/asim/go-micro/v3/config/source" 6 | "github.com/hashicorp/vault/api" 7 | ) 8 | 9 | type watcher struct { 10 | c *api.Client 11 | exit chan bool 12 | } 13 | 14 | func newWatcher(c *api.Client) *watcher { 15 | return &watcher{ 16 | c: c, 17 | exit: make(chan bool), 18 | } 19 | } 20 | 21 | func (w *watcher) Next() (*source.ChangeSet, error) { 22 | <-w.exit 23 | return nil, errors.New("url watcher stopped") 24 | } 25 | 26 | func (w *watcher) Stop() error { 27 | select { 28 | case <-w.exit: 29 | default: 30 | } 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /v3/logger/apex/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/logger/apex 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/apex/log v1.9.0 7 | github.com/asim/go-micro/v3 v3.7.1 8 | ) 9 | -------------------------------------------------------------------------------- /v3/logger/logrus/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/logger/logrus 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/sirupsen/logrus v1.8.1 8 | ) 9 | -------------------------------------------------------------------------------- /v3/logger/windowseventlog/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/korableg/go-micro/plugins/v3/logger/windowseventlog 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/stretchr/testify v1.7.0 8 | golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 9 | ) 10 | -------------------------------------------------------------------------------- /v3/logger/windowseventlog/options.go: -------------------------------------------------------------------------------- 1 | //go:build windows 2 | // +build windows 3 | 4 | package windowseventlog 5 | 6 | import "github.com/asim/go-micro/v3/logger" 7 | 8 | type src struct{} 9 | type eid struct{} 10 | 11 | type Options struct { 12 | logger.Options 13 | Src string 14 | Eid uint32 15 | } 16 | 17 | func WithSrc(namesrc string) logger.Option { 18 | return logger.SetOption(src{}, namesrc) 19 | } 20 | 21 | func WithEid(neweid uint32) logger.Option { 22 | return logger.SetOption(eid{}, neweid) 23 | } 24 | -------------------------------------------------------------------------------- /v3/logger/zap/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/logger/zap 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | go.uber.org/zap v1.17.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/logger/zerolog/README.md: -------------------------------------------------------------------------------- 1 | # Zerolog 2 | 3 | [Zerolog](https://github.com/rs/zerolog) logger implementation for __go-micro__ [meta logger](https://github.com/micro/go-micro/tree/master/logger). 4 | 5 | ## Usage 6 | 7 | ```go 8 | func ExampleWithOut() { 9 | logger.DefaultLogger = zerolog.NewLogger(logger.WithOutput(os.Stdout), logger.WithLevel(logger.DebugLevel)) 10 | 11 | logger.Infof(logger.InfoLevel, "testing: %s", "Infof") 12 | 13 | // Output: 14 | // {"level":"info","message":"testing: Infof"} 15 | } 16 | ``` 17 | -------------------------------------------------------------------------------- /v3/logger/zerolog/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/logger/zerolog 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/rs/zerolog v1.23.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/proxy/http/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/proxy/http 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/registry/cache/cache.go: -------------------------------------------------------------------------------- 1 | // Package cache provides a registry cache 2 | package cache 3 | 4 | import ( 5 | "github.com/asim/go-micro/v3/registry" 6 | "github.com/asim/go-micro/v3/registry/cache" 7 | ) 8 | 9 | // New returns a new cache 10 | func New(r registry.Registry, opts ...cache.Option) cache.Cache { 11 | return cache.New(r, opts...) 12 | } 13 | -------------------------------------------------------------------------------- /v3/registry/cache/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/cache 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/registry/cache/options.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/asim/go-micro/v3/registry/cache" 7 | ) 8 | 9 | // WithTTL sets the cache TTL 10 | func WithTTL(t time.Duration) cache.Option { 11 | return cache.WithTTL(t) 12 | } 13 | -------------------------------------------------------------------------------- /v3/registry/consul/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/consul 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/hashicorp/consul/api v1.9.0 8 | github.com/mitchellh/hashstructure v1.1.0 9 | ) 10 | -------------------------------------------------------------------------------- /v3/registry/etcd/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/etcd 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/mitchellh/hashstructure v1.1.0 8 | go.etcd.io/etcd/api/v3 v3.5.0 9 | go.etcd.io/etcd/client/v3 v3.5.0 10 | go.uber.org/zap v1.17.0 11 | ) 12 | -------------------------------------------------------------------------------- /v3/registry/eureka/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/eureka 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/cenkalti/backoff v2.2.1+incompatible // indirect 8 | github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec // indirect 9 | github.com/franela/goblin v0.0.0-20210519012713-85d372ac71e2 // indirect 10 | github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8 // indirect 11 | github.com/hudl/fargo v1.3.0 12 | github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 13 | golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d 14 | gopkg.in/gcfg.v1 v1.2.3 // indirect 15 | ) 16 | -------------------------------------------------------------------------------- /v3/registry/gossip/README.md: -------------------------------------------------------------------------------- 1 | # Gossip Registry 2 | 3 | Gossip is a zero dependency registry which uses github.com/hashicorp/memberlist to broadcast registry information 4 | via the SWIM protocol. 5 | 6 | ## Usage 7 | 8 | Start with the registry flag or env var 9 | 10 | ```bash 11 | MICRO_REGISTRY=gossip go run service.go 12 | ``` 13 | 14 | On startup you'll see something like 15 | 16 | ```bash 17 | 2018/12/06 18:17:48 Registry Listening on 192.168.1.65:56390 18 | ``` 19 | 20 | To join this gossip ring set the registry address using flag or env var 21 | 22 | ```bash 23 | MICRO_REGISTRY_ADDRESS=192.168.1.65:56390 24 | ``` 25 | -------------------------------------------------------------------------------- /v3/registry/gossip/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/gossip 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/golang/protobuf v1.5.2 8 | github.com/google/uuid v1.2.0 9 | github.com/hashicorp/memberlist v0.1.5 10 | github.com/mitchellh/hashstructure v1.1.0 11 | ) 12 | -------------------------------------------------------------------------------- /v3/registry/gossip/proto/gossip.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package gossip; 4 | 5 | // Update is the message broadcast 6 | message Update { 7 | // time to live for entry 8 | uint64 expires = 1; 9 | // type of update 10 | int32 type = 2; 11 | // what action is taken 12 | int32 action = 3; 13 | // any other associated metadata about the data 14 | map metadata = 6; 15 | // the payload data; 16 | bytes data = 7; 17 | } 18 | -------------------------------------------------------------------------------- /v3/registry/kubernetes/client/watch/watch.go: -------------------------------------------------------------------------------- 1 | package watch 2 | 3 | import "encoding/json" 4 | 5 | // Watch ... 6 | type Watch interface { 7 | Stop() 8 | ResultChan() <-chan Event 9 | } 10 | 11 | // EventType defines the possible types of events. 12 | type EventType string 13 | 14 | // EventTypes used 15 | const ( 16 | Added EventType = "ADDED" 17 | Modified EventType = "MODIFIED" 18 | Deleted EventType = "DELETED" 19 | Error EventType = "ERROR" 20 | ) 21 | 22 | // Event represents a single event to a watched resource. 23 | type Event struct { 24 | Type EventType `json:"type"` 25 | Object json.RawMessage `json:"object"` 26 | } 27 | -------------------------------------------------------------------------------- /v3/registry/kubernetes/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/kubernetes 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/registry/mdns/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/mdns 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/registry/mdns/mdns.go: -------------------------------------------------------------------------------- 1 | // Package mdns provides a multicast dns registry 2 | package mdns 3 | 4 | import ( 5 | "github.com/asim/go-micro/v3/cmd" 6 | "github.com/asim/go-micro/v3/registry" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultRegistries["mdns"] = NewRegistry 11 | } 12 | 13 | // NewRegistry returns a new mdns registry 14 | func NewRegistry(opts ...registry.Option) registry.Registry { 15 | return registry.NewRegistry(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v3/registry/memory/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/memory 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/google/uuid v1.2.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/registry/memory/memory_watcher.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/asim/go-micro/v3/registry" 7 | ) 8 | 9 | type memoryWatcher struct { 10 | exit chan bool 11 | opts registry.WatchOptions 12 | } 13 | 14 | func (m *memoryWatcher) Next() (*registry.Result, error) { 15 | // not implement so we just block until exit 16 | <-m.exit 17 | return nil, errors.New("watcher stopped") 18 | } 19 | 20 | func (m *memoryWatcher) Stop() { 21 | select { 22 | case <-m.exit: 23 | return 24 | default: 25 | close(m.exit) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /v3/registry/memory/watcher_test.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/asim/go-micro/v3/registry" 7 | ) 8 | 9 | func TestWatcher(t *testing.T) { 10 | w := &Watcher{ 11 | id: "test", 12 | res: make(chan *registry.Result), 13 | exit: make(chan bool), 14 | } 15 | 16 | go func() { 17 | w.res <- ®istry.Result{} 18 | }() 19 | 20 | _, err := w.Next() 21 | if err != nil { 22 | t.Fatal("unexpected err", err) 23 | } 24 | 25 | w.Stop() 26 | 27 | if _, err := w.Next(); err == nil { 28 | t.Fatal("expected error on Next()") 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /v3/registry/multi/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/multi 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/registry/nacos/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/nacos 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/nacos-group/nacos-sdk-go/v2 v2.0.0-Beta.1 8 | ) 9 | -------------------------------------------------------------------------------- /v3/registry/nats/assert_test.go: -------------------------------------------------------------------------------- 1 | package nats_test 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func assertNoError(tb testing.TB, actual error) { 9 | if actual != nil { 10 | tb.Errorf("expected no error, got %v", actual) 11 | } 12 | } 13 | 14 | func assertEqual(tb testing.TB, expected, actual interface{}) { 15 | if !reflect.DeepEqual(expected, actual) { 16 | tb.Errorf("expected %v, got %v", expected, actual) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v3/registry/nats/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/nats 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/nats-io/nats-server/v2 v2.1.9 // indirect 8 | github.com/nats-io/nats.go v1.10.0 9 | ) 10 | -------------------------------------------------------------------------------- /v3/registry/proxy/README.md: -------------------------------------------------------------------------------- 1 | # Proxy Registry 2 | 3 | This is a registry plugin for the micro [proxy](https://micro.mu/docs/proxy.html) 4 | 5 | ## Usage 6 | 7 | Here's a simple usage guide 8 | 9 | ### Run Proxy 10 | 11 | ``` 12 | # download 13 | go get github.com/micro/micro 14 | 15 | # run 16 | micro proxy 17 | ``` 18 | 19 | ### Import and Flag plugin 20 | 21 | ```go 22 | import _ "github.com/go-micro/plugins/v3/registry/proxy" 23 | ``` 24 | 25 | ``` 26 | go run main.go --registry=proxy 27 | ``` 28 | -------------------------------------------------------------------------------- /v3/registry/proxy/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/proxy 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/gorilla/websocket v1.4.2 8 | ) 9 | -------------------------------------------------------------------------------- /v3/registry/zookeeper/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/registry/zookeeper 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/go-zookeeper/zk v1.0.2 8 | github.com/mitchellh/hashstructure v1.1.0 9 | ) 10 | -------------------------------------------------------------------------------- /v3/selector/dns/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/selector/dns 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/selector/label/README.md: -------------------------------------------------------------------------------- 1 | # Label Selector 2 | 3 | The label selecotr is a a priority based label selector. Rather than just returning nodes with specific labels 4 | this selector orders the nodes based on a list of labels. If no labels match all the nodes are still returned. 5 | The priority based label selector is useful for such things as rudimentary AZ based routing where requests made 6 | to other services should remain in the same AZ. 7 | -------------------------------------------------------------------------------- /v3/selector/label/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/selector/label 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/selector/label/options.go: -------------------------------------------------------------------------------- 1 | package label 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/asim/go-micro/v3/selector" 7 | ) 8 | 9 | type labelKey struct{} 10 | 11 | type label struct { 12 | key string 13 | val string 14 | } 15 | 16 | // Label used in the priority label list 17 | func Label(k, v string) selector.Option { 18 | return func(o *selector.Options) { 19 | l, ok := o.Context.Value(labelKey{}).([]label) 20 | if !ok { 21 | l = []label{} 22 | } 23 | l = append(l, label{k, v}) 24 | o.Context = context.WithValue(o.Context, labelKey{}, l) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /v3/selector/registry/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/selector/registry 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/selector/registry/options.go: -------------------------------------------------------------------------------- 1 | package registry 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | "github.com/asim/go-micro/v3/selector" 8 | ) 9 | 10 | // Set the registry cache ttl 11 | func TTL(t time.Duration) selector.Option { 12 | return func(o *selector.Options) { 13 | if o.Context == nil { 14 | o.Context = context.Background() 15 | } 16 | o.Context = context.WithValue(o.Context, "selector_ttl", t) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v3/selector/registry/registry.go: -------------------------------------------------------------------------------- 1 | // Package registry uses the go-micro registry for selection 2 | package registry 3 | 4 | import ( 5 | "github.com/asim/go-micro/v3/cmd" 6 | "github.com/asim/go-micro/v3/selector" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultSelectors["registry"] = NewSelector 11 | } 12 | 13 | // NewSelector returns a new registry selector 14 | func NewSelector(opts ...selector.Option) selector.Selector { 15 | return selector.NewSelector(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v3/selector/shard/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/selector/shard 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/minio/highwayhash v1.0.2 8 | ) 9 | -------------------------------------------------------------------------------- /v3/selector/static/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/selector/static 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/server/grpc/context.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/asim/go-micro/v3/server" 7 | ) 8 | 9 | func setServerOption(k, v interface{}) server.Option { 10 | return func(o *server.Options) { 11 | if o.Context == nil { 12 | o.Context = context.Background() 13 | } 14 | o.Context = context.WithValue(o.Context, k, v) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /v3/server/grpc/response.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | "github.com/asim/go-micro/v3/codec" 5 | ) 6 | 7 | type rpcResponse struct { 8 | header map[string]string 9 | codec codec.Codec 10 | } 11 | 12 | func (r *rpcResponse) Codec() codec.Writer { 13 | return r.codec 14 | } 15 | 16 | func (r *rpcResponse) WriteHeader(hdr map[string]string) { 17 | for k, v := range hdr { 18 | r.header[k] = v 19 | } 20 | } 21 | 22 | func (r *rpcResponse) Write(b []byte) error { 23 | return r.codec.Write(&codec.Message{ 24 | Header: r.header, 25 | Body: b, 26 | }, nil) 27 | } 28 | -------------------------------------------------------------------------------- /v3/server/http/buffer.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type buffer struct { 8 | *bytes.Buffer 9 | } 10 | 11 | func (b *buffer) Close() error { 12 | b.Buffer.Reset() 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /v3/server/http/context.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/asim/go-micro/v3/server" 7 | ) 8 | 9 | func setServerOption(k, v interface{}) server.Option { 10 | return func(o *server.Options) { 11 | if o.Context == nil { 12 | o.Context = context.Background() 13 | } 14 | o.Context = context.WithValue(o.Context, k, v) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /v3/server/http/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/server/http 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/server/http/handler.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "github.com/asim/go-micro/v3/registry" 5 | "github.com/asim/go-micro/v3/server" 6 | ) 7 | 8 | type httpHandler struct { 9 | opts server.HandlerOptions 10 | eps []*registry.Endpoint 11 | hd interface{} 12 | } 13 | 14 | func (h *httpHandler) Name() string { 15 | return "handler" 16 | } 17 | 18 | func (h *httpHandler) Handler() interface{} { 19 | return h.hd 20 | } 21 | 22 | func (h *httpHandler) Endpoints() []*registry.Endpoint { 23 | return h.eps 24 | } 25 | 26 | func (h *httpHandler) Options() server.HandlerOptions { 27 | return h.opts 28 | } 29 | -------------------------------------------------------------------------------- /v3/server/mucp/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/server/mucp 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/server/mucp/mucp.go: -------------------------------------------------------------------------------- 1 | // Package mucp provides an mucp server 2 | package mucp 3 | 4 | import ( 5 | "github.com/asim/go-micro/v3/cmd" 6 | "github.com/asim/go-micro/v3/server" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultServers["mucp"] = NewServer 11 | } 12 | 13 | // NewServer returns a micro server interface 14 | func NewServer(opts ...server.Option) server.Server { 15 | return server.NewServer(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v3/store/cockroach/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/store/cockroach 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/kr/pretty v0.2.1 8 | github.com/lib/pq v1.10.2 9 | github.com/pkg/errors v0.9.1 10 | ) 11 | -------------------------------------------------------------------------------- /v3/store/consul/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/store/consul 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/hashicorp/consul/api v1.9.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/store/file/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/store/file 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/davecgh/go-spew v1.1.1 8 | github.com/kr/pretty v0.2.1 9 | go.etcd.io/bbolt v1.3.6 10 | ) 11 | -------------------------------------------------------------------------------- /v3/store/memcached/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/store/memcached 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b 8 | ) 9 | -------------------------------------------------------------------------------- /v3/store/memory/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/store/memory 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/kr/pretty v0.2.1 8 | github.com/patrickmn/go-cache v2.1.0+incompatible 9 | github.com/pkg/errors v0.9.1 10 | ) 11 | -------------------------------------------------------------------------------- /v3/store/mysql/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/store/mysql 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/go-sql-driver/mysql v1.6.0 8 | github.com/pkg/errors v0.9.1 9 | ) 10 | -------------------------------------------------------------------------------- /v3/store/redis/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/store/redis 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/go-redis/redis/v8 v8.10.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/sync/consul/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/sync/consul 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/hashicorp/consul/api v1.9.0 8 | github.com/hashicorp/go-hclog v0.16.2 9 | ) 10 | -------------------------------------------------------------------------------- /v3/sync/etcd/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/sync/etcd 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | go.etcd.io/etcd/client/v3 v3.5.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/sync/memory/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/sync/memory 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/transport/grpc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/transport/grpc 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/golang/protobuf v1.5.2 8 | google.golang.org/grpc v1.38.0 9 | ) 10 | -------------------------------------------------------------------------------- /v3/transport/grpc/proto/transport.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package go.micro.transport.grpc; 4 | 5 | service Transport { 6 | rpc Stream(stream Message) returns (stream Message) {} 7 | } 8 | 9 | message Message { 10 | map header = 1; 11 | bytes body = 2; 12 | } 13 | -------------------------------------------------------------------------------- /v3/transport/http/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/transport/http 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/transport/http/http.go: -------------------------------------------------------------------------------- 1 | // Package http returns a http2 transport using net/http 2 | package http 3 | 4 | import ( 5 | "github.com/asim/go-micro/v3/transport" 6 | ) 7 | 8 | // NewTransport returns a new http transport using net/http and supporting http2 9 | func NewTransport(opts ...transport.Option) transport.Transport { 10 | return transport.NewHTTPTransport(opts...) 11 | } 12 | -------------------------------------------------------------------------------- /v3/transport/memory/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/transport/memory 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/transport/nats/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/transport/nats 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/go-log/log v0.2.0 8 | github.com/nats-io/nats-server/v2 v2.3.0 // indirect 9 | github.com/nats-io/nats.go v1.11.0 10 | ) 11 | -------------------------------------------------------------------------------- /v3/transport/nats/options.go: -------------------------------------------------------------------------------- 1 | package nats 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/asim/go-micro/v3/transport" 7 | "github.com/nats-io/nats.go" 8 | ) 9 | 10 | type optionsKey struct{} 11 | 12 | // Options allow to inject a nats.Options struct for configuring 13 | // the nats connection 14 | func Options(nopts nats.Options) transport.Option { 15 | return func(o *transport.Options) { 16 | if o.Context == nil { 17 | o.Context = context.Background() 18 | } 19 | o.Context = context.WithValue(o.Context, optionsKey{}, nopts) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /v3/transport/quic/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/transport/quic 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/lucas-clemente/quic-go v0.21.1 8 | ) 9 | -------------------------------------------------------------------------------- /v3/transport/rabbitmq/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/transport/rabbitmq 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/google/uuid v1.2.0 8 | github.com/streadway/amqp v1.0.0 9 | ) 10 | -------------------------------------------------------------------------------- /v3/transport/tcp/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/transport/tcp 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/transport/utp/README.md: -------------------------------------------------------------------------------- 1 | # uTP Transport 2 | 3 | The uTP transport is a go-micro transport which makes use of github.com/anacrolix/utp 4 | 5 | uTP is the [Micro Transport Protocol](https://en.wikipedia.org/wiki/Micro_Transport_Protocol) an 6 | open UDP variant of the BitTorrent protocol. 7 | 8 | 9 | The uTP transport in combination with STUN allows for peer to peer communication. 10 | -------------------------------------------------------------------------------- /v3/transport/utp/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/transport/utp 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/anacrolix/envpprof v1.1.1 // indirect 7 | github.com/anacrolix/missinggo v1.3.0 // indirect 8 | github.com/anacrolix/sync v0.4.0 // indirect 9 | github.com/anacrolix/utp v0.1.0 10 | github.com/asim/go-micro/v3 v3.7.1 11 | ) 12 | -------------------------------------------------------------------------------- /v3/wrapper/breaker/gobreaker/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/breaker/gobreaker 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/sony/gobreaker v0.4.1 8 | ) 9 | -------------------------------------------------------------------------------- /v3/wrapper/breaker/hystrix/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/breaker/hystrix 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 7 | github.com/asim/go-micro/v3 v3.7.1 8 | ) 9 | -------------------------------------------------------------------------------- /v3/wrapper/endpoint/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/endpoint 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/wrapper/monitoring/prometheus/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/monitoring/prometheus 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/go-micro/plugins/v3/broker/memory v1.0.0 8 | github.com/go-micro/plugins/v3/registry/memory v1.0.0 9 | github.com/prometheus/client_golang v1.11.0 10 | github.com/prometheus/client_model v0.2.0 11 | github.com/stretchr/testify v1.7.0 12 | ) 13 | 14 | replace ( 15 | github.com/go-micro/plugins/v3/broker/memory => ../../../broker/memory 16 | github.com/go-micro/plugins/v3/registry/memory => ../../../registry/memory 17 | ) 18 | -------------------------------------------------------------------------------- /v3/wrapper/monitoring/victoriametrics/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/monitoring/victoriametrics 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/VictoriaMetrics/metrics v1.17.2 7 | github.com/asim/go-micro/v3 v3.7.1 8 | github.com/stretchr/testify v1.7.0 9 | ) 10 | -------------------------------------------------------------------------------- /v3/wrapper/ratelimiter/ratelimit/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/ratelimiter/ratelimit/v3 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/go-micro/plugins/v3/broker/memory v1.0.0 8 | github.com/go-micro/plugins/v3/registry/memory v1.0.0 9 | github.com/go-micro/plugins/v3/transport/memory v1.0.0 10 | github.com/juju/ratelimit v1.0.1 11 | ) 12 | 13 | replace ( 14 | github.com/go-micro/plugins/v3/broker/memory => ../../../broker/memory 15 | github.com/go-micro/plugins/v3/registry/memory => ../../../registry/memory 16 | github.com/go-micro/plugins/v3/transport/memory => ../../../transport/memory 17 | ) 18 | -------------------------------------------------------------------------------- /v3/wrapper/ratelimiter/uber/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/ratelimiter/uber 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | go.uber.org/ratelimit v0.2.0 8 | ) 9 | -------------------------------------------------------------------------------- /v3/wrapper/select/roundrobin/README.md: -------------------------------------------------------------------------------- 1 | # Round Robin Wrapper 2 | 3 | The round robin wrapper is a stateful client wrapper which gives you a true round robin strategy for the selector 4 | 5 | ## Usage 6 | 7 | Pass in the wrapper when you create your service 8 | 9 | ``` 10 | wrapper := roundrobin.NewClientWrapper() 11 | 12 | service := micro.NewService( 13 | micro.Name("foo"), 14 | micro.WrapClient(wrapper), 15 | ) 16 | ``` 17 | -------------------------------------------------------------------------------- /v3/wrapper/select/roundrobin/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/select/roundrobin 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/wrapper/select/shard/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/select/shard 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/wrapper/select/version/README.md: -------------------------------------------------------------------------------- 1 | # Version Wrapper 2 | 3 | The version wrapper is a stateful client wrapper which gives you a ability to select only latest version services. That suitable for easy upgrade running services without downtime. 4 | 5 | ## Usage 6 | 7 | Pass in the wrapper when you create your service 8 | 9 | ``` 10 | wrapper := version.NewClientWrapper() 11 | 12 | service := micro.NewService( 13 | micro.Name("foo"), 14 | micro.WrapClient(wrapper), 15 | ) 16 | ``` 17 | -------------------------------------------------------------------------------- /v3/wrapper/select/version/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/select/version 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/wrapper/service/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/service 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v3/wrapper/trace/awsxray/awsxray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-micro/plugins/be3f35ce64647f8712cd0578b1e27c879467cb71/v3/wrapper/trace/awsxray/awsxray.png -------------------------------------------------------------------------------- /v3/wrapper/trace/awsxray/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/trace/awsxray 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-awsxray v0.0.0-20161209120537-0d8a60b6e205 7 | github.com/asim/go-micro/v3 v3.7.1 8 | github.com/aws/aws-sdk-go v1.38.69 9 | ) 10 | -------------------------------------------------------------------------------- /v3/wrapper/trace/datadog/ext.go: -------------------------------------------------------------------------------- 1 | package datadog 2 | 3 | const ( 4 | // tagendpoint = "micro.endpoint" 5 | // tagservice = "micro.service" 6 | // tagMethod = "micro.method" 7 | tagStatus = "micro.status" 8 | tagRole = "micro.role" 9 | tagID = "micro.id" 10 | tagVersion = "micro.version" 11 | ) 12 | -------------------------------------------------------------------------------- /v3/wrapper/trace/datadog/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/trace/datadog 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/opentracing/opentracing-go v1.2.0 // indirect 8 | github.com/philhofer/fwd v1.1.1 // indirect 9 | github.com/stretchr/testify v1.7.0 10 | google.golang.org/grpc v1.38.0 11 | gopkg.in/DataDog/dd-trace-go.v1 v1.31.1 12 | ) 13 | -------------------------------------------------------------------------------- /v3/wrapper/trace/datadog/stats.go: -------------------------------------------------------------------------------- 1 | package datadog 2 | 3 | // TODO: add statd 4 | // https://github.com/DataDog/datadog-go/tree/master/statsd 5 | 6 | // StatsProfile groups metrics-related data. 7 | type StatsProfile struct { 8 | Role string 9 | } 10 | 11 | var ( 12 | // ClientProfile is used for RPC clients. 13 | ClientProfile = &StatsProfile{ 14 | Role: "micro.client", 15 | } 16 | 17 | // ServerProfile is used for RPC servers. 18 | ServerProfile = &StatsProfile{ 19 | Role: "micro.server", 20 | } 21 | ) 22 | -------------------------------------------------------------------------------- /v3/wrapper/trace/datadog/status.go: -------------------------------------------------------------------------------- 1 | package datadog 2 | 3 | import ( 4 | "google.golang.org/grpc/codes" 5 | ) 6 | 7 | var microCodeToStatusCode = map[int32]codes.Code{ 8 | 400: codes.InvalidArgument, 9 | 401: codes.Unauthenticated, 10 | 403: codes.PermissionDenied, 11 | 404: codes.NotFound, 12 | 409: codes.Aborted, 13 | 500: codes.Internal, 14 | } 15 | -------------------------------------------------------------------------------- /v3/wrapper/trace/opencensus/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/trace/opencensus 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | go.opencensus.io v0.23.0 8 | google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84 9 | ) 10 | -------------------------------------------------------------------------------- /v3/wrapper/trace/opentracing/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/trace/opentracing 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/asim/go-micro/v3 v3.7.1 7 | github.com/opentracing/opentracing-go v1.2.0 8 | github.com/stretchr/testify v1.7.0 9 | ) 10 | -------------------------------------------------------------------------------- /v3/wrapper/validator/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v3/wrapper/validator 2 | 3 | go 1.16 4 | 5 | require github.com/asim/go-micro/v3 v3.7.1 6 | -------------------------------------------------------------------------------- /v4/broker/grpc/proto/broker.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option go_package = "../broker"; 4 | 5 | service Broker { 6 | rpc Publish(Message) returns (Empty) {} 7 | } 8 | 9 | message Message { 10 | string topic = 1; 11 | string id = 2; 12 | map header = 3; 13 | bytes body = 4; 14 | } 15 | 16 | message Empty {} 17 | -------------------------------------------------------------------------------- /v4/broker/kafka/README.md: -------------------------------------------------------------------------------- 1 | # Kafka Broker 2 | 3 | 4 | ## Async Publish 5 | ```go 6 | import "github.com/Shopify/sarama" 7 | 8 | func AsyncProduceMessage() { 9 | var errorsChan = make(chan *sarama.ProducerError) 10 | var successesChan = make(chan *sarama.ProducerMessage) 11 | go func() { 12 | for err := range errorsChan { 13 | fmt.Println(err) 14 | } 15 | } 16 | go func() { 17 | for v := range successesChan { 18 | fmt.Println(v) 19 | } 20 | } 21 | b := NewBroker(AsyncProducer(errorsChan,successesChan)) 22 | b.Publish(`topic`, &broker.Message{}) 23 | } 24 | ``` 25 | -------------------------------------------------------------------------------- /v4/broker/nats/context.go: -------------------------------------------------------------------------------- 1 | package nats 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v4/broker" 7 | ) 8 | 9 | // setBrokerOption returns a function to setup a context with given value. 10 | func setBrokerOption(k, v interface{}) broker.Option { 11 | return func(o *broker.Options) { 12 | if o.Context == nil { 13 | o.Context = context.Background() 14 | } 15 | o.Context = context.WithValue(o.Context, k, v) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /v4/broker/nats/options.go: -------------------------------------------------------------------------------- 1 | package nats 2 | 3 | import ( 4 | nats "github.com/nats-io/nats.go" 5 | "go-micro.dev/v4/broker" 6 | ) 7 | 8 | type optionsKey struct{} 9 | type drainConnectionKey struct{} 10 | 11 | // Options accepts nats.Options. 12 | func Options(opts nats.Options) broker.Option { 13 | return setBrokerOption(optionsKey{}, opts) 14 | } 15 | 16 | // DrainConnection will drain subscription on close. 17 | func DrainConnection() broker.Option { 18 | return setBrokerOption(drainConnectionKey{}, struct{}{}) 19 | } 20 | -------------------------------------------------------------------------------- /v4/broker/proxy/README.md: -------------------------------------------------------------------------------- 1 | # Proxy Broker 2 | 3 | This is a broker plugin for the micro [proxy](https://micro.mu/docs/proxy.html) 4 | 5 | ## Usage 6 | 7 | Here's a simple usage guide 8 | 9 | ### Run Proxy 10 | 11 | ``` 12 | # install micro 13 | go get github.com/micro/micro 14 | 15 | # run proxy 16 | micro proxy 17 | ``` 18 | 19 | ### Import and Flag plugin 20 | 21 | ``` 22 | import _ "github.com/go-micro/plugins/v4/broker/proxy" 23 | ``` 24 | 25 | ``` 26 | go run main.go --broker=proxy 27 | ``` 28 | -------------------------------------------------------------------------------- /v4/broker/proxy/publication.go: -------------------------------------------------------------------------------- 1 | package proxy 2 | 3 | import ( 4 | "go-micro.dev/v4/broker" 5 | ) 6 | 7 | type publication struct { 8 | topic string 9 | message *broker.Message 10 | err error 11 | } 12 | 13 | func (p *publication) Topic() string { 14 | return p.topic 15 | } 16 | 17 | func (p *publication) Message() *broker.Message { 18 | return p.message 19 | } 20 | 21 | func (p *publication) Ack() error { 22 | return nil 23 | } 24 | 25 | func (p *publication) Error() error { 26 | return p.err 27 | } 28 | -------------------------------------------------------------------------------- /v4/broker/rabbitmq/auth.go: -------------------------------------------------------------------------------- 1 | package rabbitmq 2 | 3 | type ExternalAuthentication struct { 4 | } 5 | 6 | func (auth *ExternalAuthentication) Mechanism() string { 7 | return "EXTERNAL" 8 | } 9 | 10 | func (auth *ExternalAuthentication) Response() string { 11 | return "" 12 | } 13 | -------------------------------------------------------------------------------- /v4/broker/stomp/subscriber.go: -------------------------------------------------------------------------------- 1 | package stomp 2 | 3 | import ( 4 | "github.com/go-stomp/stomp/v3" 5 | "go-micro.dev/v4/broker" 6 | ) 7 | 8 | type subscriber struct { 9 | opts broker.SubscribeOptions 10 | topic string 11 | sub *stomp.Subscription 12 | } 13 | 14 | func (s *subscriber) Options() broker.SubscribeOptions { 15 | return s.opts 16 | } 17 | 18 | func (s *subscriber) Topic() string { 19 | return s.topic 20 | } 21 | 22 | func (s *subscriber) Unsubscribe() error { 23 | return s.sub.Unsubscribe() 24 | } 25 | -------------------------------------------------------------------------------- /v4/client/grpc/README.md: -------------------------------------------------------------------------------- 1 | # GRPC Client 2 | 3 | The grpc client is a [micro.Client](https://godoc.org/github.com/micro/go-micro/client#Client) compatible client. 4 | 5 | ## Overview 6 | 7 | The client makes use of the [google.golang.org/grpc](google.golang.org/grpc) framework for the underlying communication mechanism. 8 | 9 | ## Usage 10 | 11 | Specify the client to your micro service 12 | 13 | ```go 14 | import ( 15 | "github.com/micro/go-micro" 16 | "github.com/micro/go-plugins/client/grpc" 17 | ) 18 | 19 | func main() { 20 | service := micro.NewService( 21 | micro.Name("greeter"), 22 | micro.Client(grpc.NewClient()), 23 | ) 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /v4/client/http/buffer.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type buffer struct { 8 | *bytes.Buffer 9 | } 10 | 11 | func (b *buffer) Close() error { 12 | b.Buffer.Reset() 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /v4/client/http/test/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package test; 4 | 5 | message Message { 6 | int64 seq = 1; 7 | string data = 2; 8 | } 9 | -------------------------------------------------------------------------------- /v4/client/mucp/mucp.go: -------------------------------------------------------------------------------- 1 | // Package mucp provides an mucp client 2 | package mucp 3 | 4 | import ( 5 | "go-micro.dev/v4/client" 6 | "go-micro.dev/v4/util/cmd" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultClients["mucp"] = NewClient 11 | } 12 | 13 | // NewClient returns a new micro client interface. 14 | func NewClient(opts ...client.Option) client.Client { 15 | return client.NewClient(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v4/codec/bsonrpc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/codec/bsonrpc 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/go-micro/go-bson v1.0.0 7 | go-micro.dev/v4 v4.9.0 8 | ) 9 | -------------------------------------------------------------------------------- /v4/codec/json-iterator/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/codec/json-iterator 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/golang/protobuf v1.5.2 7 | github.com/json-iterator/go v1.1.11 8 | github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c 9 | go-micro.dev/v4 v4.9.0 10 | ) 11 | 12 | require ( 13 | github.com/google/go-cmp v0.5.6 // indirect 14 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 15 | github.com/modern-go/reflect2 v1.0.1 // indirect 16 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect 17 | google.golang.org/protobuf v1.26.0 // indirect 18 | ) 19 | -------------------------------------------------------------------------------- /v4/codec/jsonrpc2/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/codec/jsonrpc2 2 | 3 | go 1.17 4 | 5 | require go-micro.dev/v4 v4.9.0 6 | -------------------------------------------------------------------------------- /v4/codec/jsonrpc2/license.go: -------------------------------------------------------------------------------- 1 | // Based on powerman/rpc-codec: 2 | // The MIT License (MIT) 3 | // Copyright (c) 2015 Alex Efros 4 | package jsonrpc2 5 | -------------------------------------------------------------------------------- /v4/codec/msgpackrpc/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/codec/msgpackrpc 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/tinylib/msgp v1.1.6 7 | go-micro.dev/v4 v4.9.0 8 | ) 9 | 10 | require github.com/philhofer/fwd v1.1.1 // indirect 11 | -------------------------------------------------------------------------------- /v4/codec/segmentio/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/codec/segmentio 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/golang/protobuf v1.5.2 7 | github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c 8 | github.com/segmentio/encoding v0.1.12 9 | go-micro.dev/v4 v4.9.0 10 | ) 11 | 12 | require ( 13 | github.com/google/go-cmp v0.5.6 // indirect 14 | golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect 15 | google.golang.org/protobuf v1.26.0 // indirect 16 | ) 17 | -------------------------------------------------------------------------------- /v4/config/encoder/hcl/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/config/encoder/hcl 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/hashicorp/hcl v1.0.0 7 | go-micro.dev/v4 v4.9.0 8 | ) 9 | -------------------------------------------------------------------------------- /v4/config/encoder/hcl/hcl.go: -------------------------------------------------------------------------------- 1 | package hcl 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/hashicorp/hcl" 7 | "go-micro.dev/v4/config/encoder" 8 | ) 9 | 10 | type hclEncoder struct{} 11 | 12 | func (h hclEncoder) Encode(v interface{}) ([]byte, error) { 13 | return json.Marshal(v) 14 | } 15 | 16 | func (h hclEncoder) Decode(d []byte, v interface{}) error { 17 | return hcl.Unmarshal(d, v) 18 | } 19 | 20 | func (h hclEncoder) String() string { 21 | return "hcl" 22 | } 23 | 24 | func NewEncoder() encoder.Encoder { 25 | return hclEncoder{} 26 | } 27 | -------------------------------------------------------------------------------- /v4/config/encoder/toml/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/config/encoder/toml 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/BurntSushi/toml v0.3.1 7 | go-micro.dev/v4 v4.9.0 8 | ) 9 | -------------------------------------------------------------------------------- /v4/config/encoder/xml/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/config/encoder/xml 2 | 3 | go 1.17 4 | 5 | require go-micro.dev/v4 v4.9.0 6 | -------------------------------------------------------------------------------- /v4/config/encoder/xml/xml.go: -------------------------------------------------------------------------------- 1 | package xml 2 | 3 | import ( 4 | "encoding/xml" 5 | 6 | "go-micro.dev/v4/config/encoder" 7 | ) 8 | 9 | type xmlEncoder struct{} 10 | 11 | func (x xmlEncoder) Encode(v interface{}) ([]byte, error) { 12 | return xml.Marshal(v) 13 | } 14 | 15 | func (x xmlEncoder) Decode(d []byte, v interface{}) error { 16 | return xml.Unmarshal(d, v) 17 | } 18 | 19 | func (x xmlEncoder) String() string { 20 | return "xml" 21 | } 22 | 23 | func NewEncoder() encoder.Encoder { 24 | return xmlEncoder{} 25 | } 26 | -------------------------------------------------------------------------------- /v4/config/encoder/yaml/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/config/encoder/yaml 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/ghodss/yaml v1.0.0 7 | go-micro.dev/v4 v4.9.0 8 | ) 9 | 10 | require ( 11 | github.com/kr/text v0.2.0 // indirect 12 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect 13 | gopkg.in/yaml.v2 v2.4.0 // indirect 14 | ) 15 | -------------------------------------------------------------------------------- /v4/config/encoder/yaml/yaml.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | import ( 4 | "github.com/ghodss/yaml" 5 | "go-micro.dev/v4/config/encoder" 6 | ) 7 | 8 | type yamlEncoder struct{} 9 | 10 | func (y yamlEncoder) Encode(v interface{}) ([]byte, error) { 11 | return yaml.Marshal(v) 12 | } 13 | 14 | func (y yamlEncoder) Decode(d []byte, v interface{}) error { 15 | return yaml.Unmarshal(d, v) 16 | } 17 | 18 | func (y yamlEncoder) String() string { 19 | return "yaml" 20 | } 21 | 22 | func NewEncoder() encoder.Encoder { 23 | return yamlEncoder{} 24 | } 25 | -------------------------------------------------------------------------------- /v4/config/source/configmap/testdata/config: -------------------------------------------------------------------------------- 1 | host=0.0.0.0 2 | port=1337 -------------------------------------------------------------------------------- /v4/config/source/configmap/testdata/config 2: -------------------------------------------------------------------------------- 1 | host=0.0.0.0 2 | port=1337 -------------------------------------------------------------------------------- /v4/config/source/configmap/testdata/mongodb: -------------------------------------------------------------------------------- 1 | host=127.0.0.1 2 | port=27017 3 | user=user 4 | password=password -------------------------------------------------------------------------------- /v4/config/source/configmap/testdata/mongodb 2: -------------------------------------------------------------------------------- 1 | host=127.0.0.1 2 | port=27017 3 | user=user 4 | password=password -------------------------------------------------------------------------------- /v4/config/source/configmap/testdata/redis: -------------------------------------------------------------------------------- 1 | url=redis://127.0.0.1:6379/db01 -------------------------------------------------------------------------------- /v4/config/source/configmap/testdata/redis 2: -------------------------------------------------------------------------------- 1 | url=redis://127.0.0.1:6379/db01 -------------------------------------------------------------------------------- /v4/config/source/grpc/proto/grpc.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | service Source { 4 | rpc Read(ReadRequest) returns (ReadResponse) {}; 5 | rpc Watch(WatchRequest) returns (stream WatchResponse) {}; 6 | } 7 | 8 | message ChangeSet { 9 | bytes data = 1; 10 | string checksum = 2; 11 | string format = 3; 12 | string source = 4; 13 | int64 timestamp = 5; 14 | } 15 | 16 | message ReadRequest { 17 | string path = 1; 18 | } 19 | 20 | message ReadResponse { 21 | ChangeSet change_set = 1; 22 | } 23 | 24 | message WatchRequest { 25 | string path = 1; 26 | } 27 | 28 | message WatchResponse { 29 | ChangeSet change_set = 1; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /v4/config/source/grpc/util.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | "time" 5 | 6 | proto "github.com/go-micro/plugins/v4/config/source/grpc/proto" 7 | "go-micro.dev/v4/config/source" 8 | ) 9 | 10 | func toChangeSet(c *proto.ChangeSet) *source.ChangeSet { 11 | return &source.ChangeSet{ 12 | Data: c.Data, 13 | Checksum: c.Checksum, 14 | Format: c.Format, 15 | Timestamp: time.Unix(c.Timestamp, 0), 16 | Source: c.Source, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v4/config/source/mucp/proto/mucp.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | service Source { 4 | rpc Read(ReadRequest) returns (ReadResponse) {}; 5 | rpc Watch(WatchRequest) returns (stream WatchResponse) {}; 6 | } 7 | 8 | message ChangeSet { 9 | bytes data = 1; 10 | string checksum = 2; 11 | string format = 3; 12 | string source = 4; 13 | int64 timestamp = 5; 14 | } 15 | 16 | message ReadRequest { 17 | string path = 1; 18 | } 19 | 20 | message ReadResponse { 21 | ChangeSet change_set = 1; 22 | } 23 | 24 | message WatchRequest { 25 | string path = 1; 26 | } 27 | 28 | message WatchResponse { 29 | ChangeSet change_set = 1; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /v4/config/source/mucp/util.go: -------------------------------------------------------------------------------- 1 | package mucp 2 | 3 | import ( 4 | "time" 5 | 6 | proto "github.com/go-micro/plugins/v4/config/source/mucp/proto" 7 | "go-micro.dev/v4/config/source" 8 | ) 9 | 10 | func toChangeSet(c *proto.ChangeSet) *source.ChangeSet { 11 | return &source.ChangeSet{ 12 | Data: c.Data, 13 | Checksum: c.Checksum, 14 | Format: c.Format, 15 | Timestamp: time.Unix(c.Timestamp, 0), 16 | Source: c.Source, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v4/config/source/pkger/README.md: -------------------------------------------------------------------------------- 1 | # pkger 2 | 3 | pkger plugin for `go-config` 4 | 5 | ### Prerequisites 6 | 7 | > Install `pkger` cli 8 | 9 | ```bash 10 | go install github.com/markbates/pkger/cmd/pkger 11 | pkger -h 12 | ``` 13 | 14 | ### Packager 15 | 16 | > generating `pkged.go` with all files in `/config` as part of build pipeline 17 | 18 | ```bash 19 | pkger -o srv/greeter -include /config 20 | ``` 21 | 22 | ### Usage 23 | 24 | ```go 25 | if err := config.Load( 26 | pkger.NewSource(pkger.WithPath("/config/config.yaml")), 27 | ); err != nil { 28 | log.Fatal(err.Error()) 29 | } 30 | ``` 31 | -------------------------------------------------------------------------------- /v4/config/source/pkger/format.go: -------------------------------------------------------------------------------- 1 | package pkger 2 | 3 | import ( 4 | "strings" 5 | 6 | "go-micro.dev/v4/config/encoder" 7 | ) 8 | 9 | func format(p string, e encoder.Encoder) string { 10 | parts := strings.Split(p, ".") 11 | if len(parts) > 1 { 12 | return parts[len(parts)-1] 13 | } 14 | return e.String() 15 | } 16 | -------------------------------------------------------------------------------- /v4/config/source/pkger/options.go: -------------------------------------------------------------------------------- 1 | package pkger 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v4/config/source" 7 | ) 8 | 9 | type pkgerPathKey struct{} 10 | 11 | // WithPath sets the path to pkger. 12 | func WithPath(p string) source.Option { 13 | return func(o *source.Options) { 14 | if o.Context == nil { 15 | o.Context = context.Background() 16 | } 17 | o.Context = context.WithValue(o.Context, pkgerPathKey{}, p) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /v4/config/source/runtimevar/options.go: -------------------------------------------------------------------------------- 1 | package runtimevar 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v4/config/source" 7 | "gocloud.dev/runtimevar" 8 | ) 9 | 10 | type variableKey struct{} 11 | 12 | // WithVariable sets the runtimevar.Variable. 13 | func WithVariable(v *runtimevar.Variable) source.Option { 14 | return func(o *source.Options) { 15 | if o.Context == nil { 16 | o.Context = context.Background() 17 | } 18 | o.Context = context.WithValue(o.Context, variableKey{}, v) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /v4/config/source/url/format.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | func format(ct string) string { 8 | parts := strings.Split(ct, "/") 9 | if len(parts) <= 1 { 10 | return ct 11 | } 12 | return parts[1] 13 | } 14 | -------------------------------------------------------------------------------- /v4/config/source/url/format_test.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestFormat(t *testing.T) { 8 | testCases := []struct { 9 | contentType string 10 | format string 11 | }{ 12 | {"application/json", "json"}, 13 | {"application/xml", "xml"}, 14 | {"application/json", "json"}, 15 | } 16 | 17 | for _, c := range testCases { 18 | f := format(c.contentType) 19 | if f != c.format { 20 | t.Fatalf("failed to format %s: expected %s got %s", c.contentType, c.format, f) 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /v4/config/source/url/options.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v4/config/source" 7 | ) 8 | 9 | type urlKey struct{} 10 | 11 | func WithURL(u string) source.Option { 12 | return func(o *source.Options) { 13 | if o.Context == nil { 14 | o.Context = context.Background() 15 | } 16 | o.Context = context.WithValue(o.Context, urlKey{}, u) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v4/config/source/url/watcher.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "errors" 5 | 6 | "go-micro.dev/v4/config/source" 7 | ) 8 | 9 | type urlWatcher struct { 10 | u *urlSource 11 | exit chan bool 12 | } 13 | 14 | func newWatcher(u *urlSource) (*urlWatcher, error) { 15 | return &urlWatcher{ 16 | u: u, 17 | exit: make(chan bool), 18 | }, nil 19 | } 20 | 21 | func (u *urlWatcher) Next() (*source.ChangeSet, error) { 22 | <-u.exit 23 | return nil, errors.New("url watcher stopped") 24 | } 25 | 26 | func (u *urlWatcher) Stop() error { 27 | select { 28 | case <-u.exit: 29 | default: 30 | } 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /v4/config/source/vault/testdata/vault_init_commands: -------------------------------------------------------------------------------- 1 | vault kv put secret/data/db/auth user=myuser password=mypassword2 host=128.23.33.21 port=3307 -------------------------------------------------------------------------------- /v4/config/source/vault/testdata/vault_init_commands 2: -------------------------------------------------------------------------------- 1 | vault kv put secret/data/db/auth user=myuser password=mypassword2 host=128.23.33.21 port=3307 -------------------------------------------------------------------------------- /v4/config/source/vault/watcher.go: -------------------------------------------------------------------------------- 1 | package vault 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/hashicorp/vault/api" 7 | "go-micro.dev/v4/config/source" 8 | ) 9 | 10 | type watcher struct { 11 | c *api.Client 12 | exit chan bool 13 | } 14 | 15 | func newWatcher(c *api.Client) *watcher { 16 | return &watcher{ 17 | c: c, 18 | exit: make(chan bool), 19 | } 20 | } 21 | 22 | func (w *watcher) Next() (*source.ChangeSet, error) { 23 | <-w.exit 24 | return nil, errors.New("url watcher stopped") 25 | } 26 | 27 | func (w *watcher) Stop() error { 28 | select { 29 | case <-w.exit: 30 | default: 31 | } 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /v4/events/nats/README.md: -------------------------------------------------------------------------------- 1 | # NATS Streaming 2 | 3 | This plugin uses NATS Streaming to send and receive events. 4 | 5 | Please not that [NATS Streaming is deprecated](https://docs.nats.io/legacy/stan) and will be no longer receive security fixes after June of 2023. 6 | 7 | You should instead [NATS JetStream](https://docs.nats.io/nats-concepts/jetstream) and the [go-micro natsjs plugin](https://github.com/asim/go-micro/tree/master/plugins/events/natsjs). 8 | -------------------------------------------------------------------------------- /v4/events/natsjs/README.md: -------------------------------------------------------------------------------- 1 | # NATS JetStream 2 | 3 | This plugin uses NATS with JetStream to send and receive events. 4 | -------------------------------------------------------------------------------- /v4/logger/apex/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/logger/apex 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/apex/log v1.9.0 7 | go-micro.dev/v4 v4.9.0 8 | ) 9 | 10 | require ( 11 | github.com/fatih/color v1.7.0 // indirect 12 | github.com/google/uuid v1.2.0 // indirect 13 | github.com/mattn/go-colorable v0.1.8 // indirect 14 | github.com/mattn/go-isatty v0.0.12 // indirect 15 | github.com/pkg/errors v0.9.1 // indirect 16 | golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79 // indirect 17 | ) 18 | -------------------------------------------------------------------------------- /v4/logger/logrus/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/logger/logrus 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/sirupsen/logrus v1.8.1 7 | go-micro.dev/v4 v4.9.0 8 | ) 9 | 10 | require ( 11 | github.com/google/uuid v1.2.0 // indirect 12 | golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79 // indirect 13 | ) 14 | -------------------------------------------------------------------------------- /v4/logger/windowseventlog/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/logger/windowseventlog 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/stretchr/testify v1.7.0 7 | go-micro.dev/v4 v4.9.0 8 | golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 9 | ) 10 | 11 | require ( 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/google/uuid v1.2.0 // indirect 14 | github.com/kr/text v0.2.0 // indirect 15 | github.com/pmezard/go-difflib v1.0.0 // indirect 16 | gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect 17 | gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect 18 | ) 19 | -------------------------------------------------------------------------------- /v4/logger/windowseventlog/options.go: -------------------------------------------------------------------------------- 1 | //go:build windows 2 | // +build windows 3 | 4 | package windowseventlog 5 | 6 | import "go-micro.dev/v4/logger" 7 | 8 | type src struct{} 9 | type eid struct{} 10 | 11 | type Options struct { 12 | logger.Options 13 | Src string 14 | Eid uint32 15 | } 16 | 17 | func WithSrc(namesrc string) logger.Option { 18 | return logger.SetOption(src{}, namesrc) 19 | } 20 | 21 | func WithEid(neweid uint32) logger.Option { 22 | return logger.SetOption(eid{}, neweid) 23 | } 24 | -------------------------------------------------------------------------------- /v4/logger/zap/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/logger/zap 2 | 3 | go 1.17 4 | 5 | require ( 6 | go-micro.dev/v4 v4.9.0 7 | go.uber.org/zap v1.17.0 8 | ) 9 | 10 | require ( 11 | github.com/google/uuid v1.2.0 // indirect 12 | go.uber.org/atomic v1.7.0 // indirect 13 | go.uber.org/multierr v1.6.0 // indirect 14 | gopkg.in/yaml.v2 v2.4.0 // indirect 15 | ) 16 | -------------------------------------------------------------------------------- /v4/logger/zerolog/README.md: -------------------------------------------------------------------------------- 1 | # Zerolog 2 | 3 | [Zerolog](https://github.com/rs/zerolog) logger implementation for __go-micro__ [meta logger](https://github.com/micro/go-micro/tree/master/logger). 4 | 5 | ## Usage 6 | 7 | ```go 8 | func ExampleWithOut() { 9 | logger.DefaultLogger = zerolog.NewLogger(logger.WithOutput(os.Stdout), logger.WithLevel(logger.DebugLevel)) 10 | 11 | logger.Infof(logger.InfoLevel, "testing: %s", "Infof") 12 | 13 | // Output: 14 | // {"level":"info","message":"testing: Infof"} 15 | } 16 | ``` 17 | -------------------------------------------------------------------------------- /v4/logger/zerolog/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/logger/zerolog 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/rs/zerolog v1.23.0 7 | go-micro.dev/v4 v4.9.0 8 | ) 9 | 10 | require ( 11 | github.com/google/uuid v1.2.0 // indirect 12 | github.com/pkg/errors v0.9.1 // indirect 13 | ) 14 | -------------------------------------------------------------------------------- /v4/registry/cache/cache.go: -------------------------------------------------------------------------------- 1 | // Package cache provides a registry cache 2 | package cache 3 | 4 | import ( 5 | "go-micro.dev/v4/registry" 6 | "go-micro.dev/v4/registry/cache" 7 | ) 8 | 9 | // New returns a new cache. 10 | func New(r registry.Registry, opts ...cache.Option) cache.Cache { 11 | return cache.New(r, opts...) 12 | } 13 | -------------------------------------------------------------------------------- /v4/registry/cache/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/registry/cache 2 | 3 | go 1.17 4 | 5 | require go-micro.dev/v4 v4.9.0 6 | 7 | require ( 8 | github.com/google/uuid v1.2.0 // indirect 9 | github.com/miekg/dns v1.1.43 // indirect 10 | golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect 11 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect 12 | golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79 // indirect 13 | ) 14 | -------------------------------------------------------------------------------- /v4/registry/cache/options.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "time" 5 | 6 | "go-micro.dev/v4/registry/cache" 7 | ) 8 | 9 | // WithTTL sets the cache TTL. 10 | func WithTTL(t time.Duration) cache.Option { 11 | return cache.WithTTL(t) 12 | } 13 | -------------------------------------------------------------------------------- /v4/registry/gossip/README.md: -------------------------------------------------------------------------------- 1 | # Gossip Registry 2 | 3 | Gossip is a zero dependency registry which uses github.com/hashicorp/memberlist to broadcast registry information 4 | via the SWIM protocol. 5 | 6 | ## Usage 7 | 8 | Start with the registry flag or env var 9 | 10 | ```bash 11 | MICRO_REGISTRY=gossip go run service.go 12 | ``` 13 | 14 | On startup you'll see something like 15 | 16 | ```bash 17 | 2018/12/06 18:17:48 Registry Listening on 192.168.1.65:56390 18 | ``` 19 | 20 | To join this gossip ring set the registry address using flag or env var 21 | 22 | ```bash 23 | MICRO_REGISTRY_ADDRESS=192.168.1.65:56390 24 | ``` 25 | -------------------------------------------------------------------------------- /v4/registry/gossip/proto/gossip.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package gossip; 4 | 5 | // Update is the message broadcast 6 | message Update { 7 | // time to live for entry 8 | uint64 expires = 1; 9 | // type of update 10 | int32 type = 2; 11 | // what action is taken 12 | int32 action = 3; 13 | // any other associated metadata about the data 14 | map metadata = 6; 15 | // the payload data; 16 | bytes data = 7; 17 | } 18 | -------------------------------------------------------------------------------- /v4/registry/mdns/mdns.go: -------------------------------------------------------------------------------- 1 | // Package mdns provides a multicast dns registry 2 | package mdns 3 | 4 | import ( 5 | "go-micro.dev/v4/registry" 6 | "go-micro.dev/v4/util/cmd" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultRegistries["mdns"] = NewRegistry 11 | } 12 | 13 | // NewRegistry returns a new mdns registry. 14 | func NewRegistry(opts ...registry.Option) registry.Registry { 15 | return registry.NewRegistry(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v4/registry/memory/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/registry/memory 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/google/uuid v1.2.0 7 | go-micro.dev/v4 v4.9.0 8 | ) 9 | 10 | require ( 11 | github.com/miekg/dns v1.1.43 // indirect 12 | golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect 13 | golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79 // indirect 14 | ) 15 | -------------------------------------------------------------------------------- /v4/registry/memory/memory_watcher.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | import ( 4 | "errors" 5 | 6 | "go-micro.dev/v4/registry" 7 | ) 8 | 9 | type memoryWatcher struct { 10 | exit chan bool 11 | opts registry.WatchOptions 12 | } 13 | 14 | func (m *memoryWatcher) Next() (*registry.Result, error) { 15 | // not implement so we just block until exit 16 | <-m.exit 17 | return nil, errors.New("watcher stopped") 18 | } 19 | 20 | func (m *memoryWatcher) Stop() { 21 | select { 22 | case <-m.exit: 23 | return 24 | default: 25 | close(m.exit) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /v4/registry/memory/watcher_test.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | import ( 4 | "testing" 5 | 6 | "go-micro.dev/v4/registry" 7 | ) 8 | 9 | func TestWatcher(t *testing.T) { 10 | w := &Watcher{ 11 | id: "test", 12 | res: make(chan *registry.Result), 13 | exit: make(chan bool), 14 | } 15 | 16 | go func() { 17 | w.res <- ®istry.Result{} 18 | }() 19 | 20 | _, err := w.Next() 21 | if err != nil { 22 | t.Fatal("unexpected err", err) 23 | } 24 | 25 | w.Stop() 26 | 27 | if _, err := w.Next(); err == nil { 28 | t.Fatal("expected error on Next()") 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /v4/registry/multi/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/registry/multi 2 | 3 | go 1.17 4 | 5 | require go-micro.dev/v4 v4.9.0 6 | 7 | require ( 8 | github.com/google/uuid v1.2.0 // indirect 9 | github.com/miekg/dns v1.1.43 // indirect 10 | golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect 11 | golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79 // indirect 12 | ) 13 | -------------------------------------------------------------------------------- /v4/registry/nats/assert_test.go: -------------------------------------------------------------------------------- 1 | package nats_test 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func assertNoError(tb testing.TB, actual error) { 9 | if actual != nil { 10 | tb.Errorf("expected no error, got %v", actual) 11 | } 12 | } 13 | 14 | func assertEqual(tb testing.TB, expected, actual interface{}) { 15 | if !reflect.DeepEqual(expected, actual) { 16 | tb.Errorf("expected %v, got %v", expected, actual) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v4/registry/proxy/README.md: -------------------------------------------------------------------------------- 1 | # Proxy Registry 2 | 3 | This is a registry plugin for the micro [proxy](https://micro.mu/docs/proxy.html) 4 | 5 | ## Usage 6 | 7 | Here's a simple usage guide 8 | 9 | ### Run Proxy 10 | 11 | ``` 12 | # download 13 | go get github.com/micro/micro 14 | 15 | # run 16 | micro proxy 17 | ``` 18 | 19 | ### Import and Flag plugin 20 | 21 | ```go 22 | import _ "github.com/go-micro/plugins/v4/registry/proxy" 23 | ``` 24 | 25 | ``` 26 | go run main.go --registry=proxy 27 | ``` 28 | -------------------------------------------------------------------------------- /v4/selector/dns/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/selector/dns 2 | 3 | go 1.17 4 | 5 | require go-micro.dev/v4 v4.9.0 6 | 7 | require ( 8 | github.com/google/uuid v1.2.0 // indirect 9 | github.com/miekg/dns v1.1.43 // indirect 10 | golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect 11 | golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect 12 | golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79 // indirect 13 | ) 14 | -------------------------------------------------------------------------------- /v4/selector/label/README.md: -------------------------------------------------------------------------------- 1 | # Label Selector 2 | 3 | The label selecotr is a a priority based label selector. Rather than just returning nodes with specific labels 4 | this selector orders the nodes based on a list of labels. If no labels match all the nodes are still returned. 5 | The priority based label selector is useful for such things as rudimentary AZ based routing where requests made 6 | to other services should remain in the same AZ. 7 | -------------------------------------------------------------------------------- /v4/selector/label/options.go: -------------------------------------------------------------------------------- 1 | package label 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v4/selector" 7 | ) 8 | 9 | type labelKey struct{} 10 | 11 | type label struct { 12 | key string 13 | val string 14 | } 15 | 16 | // Label used in the priority label list. 17 | func Label(k, v string) selector.Option { 18 | return func(o *selector.Options) { 19 | l, ok := o.Context.Value(labelKey{}).([]label) 20 | if !ok { 21 | l = []label{} 22 | } 23 | l = append(l, label{k, v}) 24 | o.Context = context.WithValue(o.Context, labelKey{}, l) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /v4/selector/registry/options.go: -------------------------------------------------------------------------------- 1 | package registry 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | "go-micro.dev/v4/selector" 8 | ) 9 | 10 | // Set the registry cache ttl. 11 | func TTL(t time.Duration) selector.Option { 12 | return func(o *selector.Options) { 13 | if o.Context == nil { 14 | o.Context = context.Background() 15 | } 16 | o.Context = context.WithValue(o.Context, "selector_ttl", t) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v4/selector/registry/registry.go: -------------------------------------------------------------------------------- 1 | // Package registry uses the go-micro registry for selection 2 | package registry 3 | 4 | import ( 5 | "go-micro.dev/v4/selector" 6 | "go-micro.dev/v4/util/cmd" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultSelectors["registry"] = NewSelector 11 | } 12 | 13 | // NewSelector returns a new registry selector. 14 | func NewSelector(opts ...selector.Option) selector.Selector { 15 | return selector.NewSelector(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v4/server/grpc/context.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v4/server" 7 | ) 8 | 9 | func setServerOption(k, v interface{}) server.Option { 10 | return func(o *server.Options) { 11 | if o.Context == nil { 12 | o.Context = context.Background() 13 | } 14 | o.Context = context.WithValue(o.Context, k, v) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /v4/server/grpc/response.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | "go-micro.dev/v4/codec" 5 | ) 6 | 7 | type rpcResponse struct { 8 | header map[string]string 9 | codec codec.Codec 10 | } 11 | 12 | func (r *rpcResponse) Codec() codec.Writer { 13 | return r.codec 14 | } 15 | 16 | func (r *rpcResponse) WriteHeader(hdr map[string]string) { 17 | for k, v := range hdr { 18 | r.header[k] = v 19 | } 20 | } 21 | 22 | func (r *rpcResponse) Write(b []byte) error { 23 | return r.codec.Write(&codec.Message{ 24 | Header: r.header, 25 | Body: b, 26 | }, nil) 27 | } 28 | -------------------------------------------------------------------------------- /v4/server/http/buffer.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type buffer struct { 8 | *bytes.Buffer 9 | } 10 | 11 | func (b *buffer) Close() error { 12 | b.Buffer.Reset() 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /v4/server/http/context.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v4/server" 7 | ) 8 | 9 | func setServerOption(k, v interface{}) server.Option { 10 | return func(o *server.Options) { 11 | if o.Context == nil { 12 | o.Context = context.Background() 13 | } 14 | o.Context = context.WithValue(o.Context, k, v) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /v4/server/http/handler.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "go-micro.dev/v4/registry" 5 | "go-micro.dev/v4/server" 6 | ) 7 | 8 | type httpHandler struct { 9 | opts server.HandlerOptions 10 | eps []*registry.Endpoint 11 | hd interface{} 12 | } 13 | 14 | func (h *httpHandler) Name() string { 15 | return "handler" 16 | } 17 | 18 | func (h *httpHandler) Handler() interface{} { 19 | return h.hd 20 | } 21 | 22 | func (h *httpHandler) Endpoints() []*registry.Endpoint { 23 | return h.eps 24 | } 25 | 26 | func (h *httpHandler) Options() server.HandlerOptions { 27 | return h.opts 28 | } 29 | -------------------------------------------------------------------------------- /v4/server/mucp/mucp.go: -------------------------------------------------------------------------------- 1 | // Package mucp provides an mucp server 2 | package mucp 3 | 4 | import ( 5 | "go-micro.dev/v4/server" 6 | "go-micro.dev/v4/util/cmd" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultServers["mucp"] = NewServer 11 | } 12 | 13 | // NewServer returns a micro server interface. 14 | func NewServer(opts ...server.Option) server.Server { 15 | return server.NewServer(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v4/store/file/options.go: -------------------------------------------------------------------------------- 1 | package file 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v4/store" 7 | ) 8 | 9 | type dirOptionKey struct{} 10 | 11 | // DirOption is a file store Option to set the directory for the file store. 12 | func DirOption(dir string) store.Option { 13 | return func(o *store.Options) { 14 | if o.Context == nil { 15 | o.Context = context.Background() 16 | } 17 | o.Context = context.WithValue(o.Context, dirOptionKey{}, dir) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /v4/store/nats-js-kv/context.go: -------------------------------------------------------------------------------- 1 | package natsjskv 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v4/store" 7 | ) 8 | 9 | // setStoreOption returns a function to setup a context with given value. 10 | func setStoreOption(k, v interface{}) store.Option { 11 | return func(o *store.Options) { 12 | if o.Context == nil { 13 | o.Context = context.Background() 14 | } 15 | 16 | o.Context = context.WithValue(o.Context, k, v) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v4/store/nats-js/context.go: -------------------------------------------------------------------------------- 1 | package natsjs 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v4/store" 7 | ) 8 | 9 | // setStoreOption returns a function to setup a context with given value. 10 | func setStoreOption(k, v interface{}) store.Option { 11 | return func(o *store.Options) { 12 | if o.Context == nil { 13 | o.Context = context.Background() 14 | } 15 | o.Context = context.WithValue(o.Context, k, v) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /v4/sync/memory/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/sync/memory 2 | 3 | go 1.17 4 | 5 | require go-micro.dev/v4 v4.9.0 6 | 7 | require github.com/google/uuid v1.2.0 // indirect 8 | -------------------------------------------------------------------------------- /v4/transport/grpc/proto/transport.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package go.micro.transport.grpc; 4 | 5 | service Transport { 6 | rpc Stream(stream Message) returns (stream Message) {} 7 | } 8 | 9 | message Message { 10 | map header = 1; 11 | bytes body = 2; 12 | } 13 | -------------------------------------------------------------------------------- /v4/transport/http/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-micro/plugins/v4/transport/http 2 | 3 | go 1.17 4 | 5 | require go-micro.dev/v4 v4.9.0 6 | 7 | require ( 8 | github.com/google/uuid v1.2.0 // indirect 9 | golang.org/x/net v0.0.0-20210510120150-4163338589ed // indirect 10 | golang.org/x/text v0.3.6 // indirect 11 | ) 12 | -------------------------------------------------------------------------------- /v4/transport/http/http.go: -------------------------------------------------------------------------------- 1 | // Package http returns a http2 transport using net/http 2 | package http 3 | 4 | import ( 5 | "go-micro.dev/v4/transport" 6 | ) 7 | 8 | // NewTransport returns a new http transport using net/http and supporting http2. 9 | func NewTransport(opts ...transport.Option) transport.Transport { 10 | return transport.NewHTTPTransport(opts...) 11 | } 12 | -------------------------------------------------------------------------------- /v4/transport/http/options.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | 7 | "go-micro.dev/v4/transport" 8 | ) 9 | 10 | // Handle registers the handler for the given pattern. 11 | func Handle(pattern string, handler http.Handler) transport.Option { 12 | return func(o *transport.Options) { 13 | if o.Context == nil { 14 | o.Context = context.Background() 15 | } 16 | handlers, ok := o.Context.Value("http_handlers").(map[string]http.Handler) 17 | if !ok { 18 | handlers = make(map[string]http.Handler) 19 | } 20 | handlers[pattern] = handler 21 | o.Context = context.WithValue(o.Context, "http_handlers", handlers) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /v4/transport/nats/options.go: -------------------------------------------------------------------------------- 1 | package nats 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/nats-io/nats.go" 7 | "go-micro.dev/v4/transport" 8 | ) 9 | 10 | type optionsKey struct{} 11 | 12 | // Options allow to inject a nats.Options struct for configuring 13 | // the nats connection. 14 | func Options(nopts nats.Options) transport.Option { 15 | return func(o *transport.Options) { 16 | if o.Context == nil { 17 | o.Context = context.Background() 18 | } 19 | o.Context = context.WithValue(o.Context, optionsKey{}, nopts) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /v4/transport/utp/README.md: -------------------------------------------------------------------------------- 1 | # uTP Transport 2 | 3 | The uTP transport is a go-micro transport which makes use of github.com/anacrolix/utp 4 | 5 | uTP is the [Micro Transport Protocol](https://en.wikipedia.org/wiki/Micro_Transport_Protocol) an 6 | open UDP variant of the BitTorrent protocol. 7 | 8 | 9 | The uTP transport in combination with STUN allows for peer to peer communication. 10 | -------------------------------------------------------------------------------- /v4/wrapper/select/roundrobin/README.md: -------------------------------------------------------------------------------- 1 | # Round Robin Wrapper 2 | 3 | The round robin wrapper is a stateful client wrapper which gives you a true round robin strategy for the selector 4 | 5 | ## Usage 6 | 7 | Pass in the wrapper when you create your service 8 | 9 | ``` 10 | wrapper := roundrobin.NewClientWrapper() 11 | 12 | service := micro.NewService( 13 | micro.Name("foo"), 14 | micro.WrapClient(wrapper), 15 | ) 16 | ``` 17 | -------------------------------------------------------------------------------- /v4/wrapper/select/version/README.md: -------------------------------------------------------------------------------- 1 | # Version Wrapper 2 | 3 | The version wrapper is a stateful client wrapper which gives you a ability to select only latest version services. That suitable for easy upgrade running services without downtime. 4 | 5 | ## Usage 6 | 7 | Pass in the wrapper when you create your service 8 | 9 | ``` 10 | wrapper := version.NewClientWrapper() 11 | 12 | service := micro.NewService( 13 | micro.Name("foo"), 14 | micro.WrapClient(wrapper), 15 | ) 16 | ``` 17 | -------------------------------------------------------------------------------- /v4/wrapper/trace/awsxray/awsxray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-micro/plugins/be3f35ce64647f8712cd0578b1e27c879467cb71/v4/wrapper/trace/awsxray/awsxray.png -------------------------------------------------------------------------------- /v4/wrapper/trace/datadog/ext.go: -------------------------------------------------------------------------------- 1 | package datadog 2 | 3 | const ( 4 | // tagendpoint = "micro.endpoint" 5 | // tagservice = "micro.service" 6 | // tagMethod = "micro.method". 7 | tagStatus = "micro.status" 8 | tagRole = "micro.role" 9 | tagID = "micro.id" 10 | tagVersion = "micro.version" 11 | ) 12 | -------------------------------------------------------------------------------- /v4/wrapper/trace/datadog/stats.go: -------------------------------------------------------------------------------- 1 | package datadog 2 | 3 | // TODO: add statd 4 | // https://github.com/DataDog/datadog-go/tree/master/statsd 5 | 6 | // StatsProfile groups metrics-related data. 7 | type StatsProfile struct { 8 | Role string 9 | } 10 | 11 | var ( 12 | // ClientProfile is used for RPC clients. 13 | ClientProfile = &StatsProfile{ 14 | Role: "micro.client", 15 | } 16 | 17 | // ServerProfile is used for RPC servers. 18 | ServerProfile = &StatsProfile{ 19 | Role: "micro.server", 20 | } 21 | ) 22 | -------------------------------------------------------------------------------- /v4/wrapper/trace/datadog/status.go: -------------------------------------------------------------------------------- 1 | package datadog 2 | 3 | import ( 4 | "google.golang.org/grpc/codes" 5 | ) 6 | 7 | var microCodeToStatusCode = map[int32]codes.Code{ 8 | 400: codes.InvalidArgument, 9 | 401: codes.Unauthenticated, 10 | 403: codes.PermissionDenied, 11 | 404: codes.NotFound, 12 | 409: codes.Aborted, 13 | 500: codes.Internal, 14 | } 15 | -------------------------------------------------------------------------------- /v4/wrapper/trace/opentelemetry/README.md: -------------------------------------------------------------------------------- 1 | # OpenTelemetry wrappers 2 | 3 | OpenTelemetry wrappers propagate traces (spans) accross services. 4 | 5 | ## Usage 6 | 7 | ```go 8 | service := micro.NewService( 9 | micro.Name("go.micro.srv.greeter"), 10 | micro.WrapClient(opentelemetry.NewClientWrapper()), 11 | micro.WrapHandler(open.NewHandlerWrapper()), 12 | micro.WrapSubscriber(opentelemetry.NewSubscriberWrapper()), 13 | ) 14 | ``` -------------------------------------------------------------------------------- /v4/wrapper/validator/validator.go: -------------------------------------------------------------------------------- 1 | package validator 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v4/errors" 7 | "go-micro.dev/v4/server" 8 | ) 9 | 10 | type Validator interface { 11 | Validate() error 12 | } 13 | 14 | func NewHandlerWrapper() server.HandlerWrapper { 15 | return func(fn server.HandlerFunc) server.HandlerFunc { 16 | return func(ctx context.Context, req server.Request, rsp interface{}) error { 17 | if v, ok := req.Body().(Validator); ok { 18 | if err := v.Validate(); err != nil { 19 | return errors.BadRequest(req.Service(), "%v", err) 20 | } 21 | } 22 | return fn(ctx, req, rsp) 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /v5/broker/grpc/proto/broker.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | option go_package = "../broker"; 4 | 5 | service Broker { 6 | rpc Publish(Message) returns (Empty) {} 7 | } 8 | 9 | message Message { 10 | string topic = 1; 11 | string id = 2; 12 | map header = 3; 13 | bytes body = 4; 14 | } 15 | 16 | message Empty {} 17 | -------------------------------------------------------------------------------- /v5/broker/kafka/README.md: -------------------------------------------------------------------------------- 1 | # Kafka Broker 2 | 3 | 4 | ## Async Publish 5 | ```go 6 | import "github.com/Shopify/sarama" 7 | 8 | func AsyncProduceMessage() { 9 | var errorsChan = make(chan *sarama.ProducerError) 10 | var successesChan = make(chan *sarama.ProducerMessage) 11 | go func() { 12 | for err := range errorsChan { 13 | fmt.Println(err) 14 | } 15 | } 16 | go func() { 17 | for v := range successesChan { 18 | fmt.Println(v) 19 | } 20 | } 21 | b := NewBroker(AsyncProducer(errorsChan,successesChan)) 22 | b.Publish(`topic`, &broker.Message{}) 23 | } 24 | ``` 25 | -------------------------------------------------------------------------------- /v5/broker/nats/context.go: -------------------------------------------------------------------------------- 1 | package nats 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v5/broker" 7 | ) 8 | 9 | // setBrokerOption returns a function to setup a context with given value. 10 | func setBrokerOption(k, v interface{}) broker.Option { 11 | return func(o *broker.Options) { 12 | if o.Context == nil { 13 | o.Context = context.Background() 14 | } 15 | o.Context = context.WithValue(o.Context, k, v) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /v5/broker/nats/options.go: -------------------------------------------------------------------------------- 1 | package nats 2 | 3 | import ( 4 | nats "github.com/nats-io/nats.go" 5 | "go-micro.dev/v5/broker" 6 | ) 7 | 8 | type optionsKey struct{} 9 | type drainConnectionKey struct{} 10 | 11 | // Options accepts nats.Options. 12 | func Options(opts nats.Options) broker.Option { 13 | return setBrokerOption(optionsKey{}, opts) 14 | } 15 | 16 | // DrainConnection will drain subscription on close. 17 | func DrainConnection() broker.Option { 18 | return setBrokerOption(drainConnectionKey{}, struct{}{}) 19 | } 20 | -------------------------------------------------------------------------------- /v5/broker/proxy/README.md: -------------------------------------------------------------------------------- 1 | # Proxy Broker 2 | 3 | This is a broker plugin for the micro [proxy](https://micro.mu/docs/proxy.html) 4 | 5 | ## Usage 6 | 7 | Here's a simple usage guide 8 | 9 | ### Run Proxy 10 | 11 | ``` 12 | # install mu 13 | go install github.com/micro/micro/v5/mu@latest 14 | 15 | # run proxy 16 | mu proxy 17 | ``` 18 | 19 | ### Import and Flag plugin 20 | 21 | ``` 22 | import _ "github.com/micro/plugins/v5/broker/proxy" 23 | ``` 24 | 25 | ``` 26 | go run main.go --broker=proxy 27 | ``` 28 | -------------------------------------------------------------------------------- /v5/broker/proxy/publication.go: -------------------------------------------------------------------------------- 1 | package proxy 2 | 3 | import ( 4 | "go-micro.dev/v5/broker" 5 | ) 6 | 7 | type publication struct { 8 | topic string 9 | message *broker.Message 10 | err error 11 | } 12 | 13 | func (p *publication) Topic() string { 14 | return p.topic 15 | } 16 | 17 | func (p *publication) Message() *broker.Message { 18 | return p.message 19 | } 20 | 21 | func (p *publication) Ack() error { 22 | return nil 23 | } 24 | 25 | func (p *publication) Error() error { 26 | return p.err 27 | } 28 | -------------------------------------------------------------------------------- /v5/broker/rabbitmq/auth.go: -------------------------------------------------------------------------------- 1 | package rabbitmq 2 | 3 | type ExternalAuthentication struct { 4 | } 5 | 6 | func (auth *ExternalAuthentication) Mechanism() string { 7 | return "EXTERNAL" 8 | } 9 | 10 | func (auth *ExternalAuthentication) Response() string { 11 | return "" 12 | } 13 | -------------------------------------------------------------------------------- /v5/broker/stomp/subscriber.go: -------------------------------------------------------------------------------- 1 | package stomp 2 | 3 | import ( 4 | "github.com/go-stomp/stomp/v3" 5 | "go-micro.dev/v5/broker" 6 | ) 7 | 8 | type subscriber struct { 9 | opts broker.SubscribeOptions 10 | topic string 11 | sub *stomp.Subscription 12 | } 13 | 14 | func (s *subscriber) Options() broker.SubscribeOptions { 15 | return s.opts 16 | } 17 | 18 | func (s *subscriber) Topic() string { 19 | return s.topic 20 | } 21 | 22 | func (s *subscriber) Unsubscribe() error { 23 | return s.sub.Unsubscribe() 24 | } 25 | -------------------------------------------------------------------------------- /v5/client/grpc/README.md: -------------------------------------------------------------------------------- 1 | # GRPC Client 2 | 3 | The grpc client is a [micro.Client](https://godoc.org/github.com/micro/go-micro/client#Client) compatible client. 4 | 5 | ## Overview 6 | 7 | The client makes use of the [google.golang.org/grpc](google.golang.org/grpc) framework for the underlying communication mechanism. 8 | 9 | ## Usage 10 | 11 | Specify the client to your micro service 12 | 13 | ```go 14 | import ( 15 | "github.com/micro/go-micro" 16 | "github.com/micro/go-plugins/client/grpc" 17 | ) 18 | 19 | func main() { 20 | service := micro.NewService( 21 | micro.Name("greeter"), 22 | micro.Client(grpc.NewClient()), 23 | ) 24 | } 25 | ``` 26 | -------------------------------------------------------------------------------- /v5/client/http/buffer.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type buffer struct { 8 | *bytes.Buffer 9 | } 10 | 11 | func (b *buffer) Close() error { 12 | b.Buffer.Reset() 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /v5/client/http/test/test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package test; 4 | 5 | message Message { 6 | int64 seq = 1; 7 | string data = 2; 8 | } 9 | -------------------------------------------------------------------------------- /v5/client/mucp/mucp.go: -------------------------------------------------------------------------------- 1 | // Package mucp provides an mucp client 2 | package mucp 3 | 4 | import ( 5 | "go-micro.dev/v5/client" 6 | "go-micro.dev/v5/cmd" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultClients["mucp"] = NewClient 11 | } 12 | 13 | // NewClient returns a new micro client interface. 14 | func NewClient(opts ...client.Option) client.Client { 15 | return client.NewClient(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v5/codec/json-iterator/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/micro/plugins/v5/codec/json-iterator 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/golang/protobuf v1.5.4 7 | github.com/json-iterator/go v1.1.12 8 | github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c 9 | go-micro.dev/v5 v5.2.0 10 | ) 11 | 12 | require ( 13 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 14 | github.com/modern-go/reflect2 v1.0.2 // indirect 15 | google.golang.org/protobuf v1.33.0 // indirect 16 | ) 17 | -------------------------------------------------------------------------------- /v5/codec/jsonrpc2/license.go: -------------------------------------------------------------------------------- 1 | // Based on powerman/rpc-codec: 2 | // The MIT License (MIT) 3 | // Copyright (c) 2015 Alex Efros 4 | package jsonrpc2 5 | -------------------------------------------------------------------------------- /v5/codec/segmentio/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/micro/plugins/v5/codec/segmentio 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/golang/protobuf v1.5.4 7 | github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c 8 | github.com/segmentio/encoding v0.1.12 9 | go-micro.dev/v5 v5.2.0 10 | ) 11 | 12 | require google.golang.org/protobuf v1.33.0 // indirect 13 | -------------------------------------------------------------------------------- /v5/config/encoder/hcl/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/micro/plugins/v5/config/encoder/hcl 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/hashicorp/hcl v1.0.0 7 | go-micro.dev/v5 v5.2.0 8 | ) 9 | -------------------------------------------------------------------------------- /v5/config/encoder/hcl/hcl.go: -------------------------------------------------------------------------------- 1 | package hcl 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/hashicorp/hcl" 7 | "go-micro.dev/v5/config/encoder" 8 | ) 9 | 10 | type hclEncoder struct{} 11 | 12 | func (h hclEncoder) Encode(v interface{}) ([]byte, error) { 13 | return json.Marshal(v) 14 | } 15 | 16 | func (h hclEncoder) Decode(d []byte, v interface{}) error { 17 | return hcl.Unmarshal(d, v) 18 | } 19 | 20 | func (h hclEncoder) String() string { 21 | return "hcl" 22 | } 23 | 24 | func NewEncoder() encoder.Encoder { 25 | return hclEncoder{} 26 | } 27 | -------------------------------------------------------------------------------- /v5/config/encoder/xml/xml.go: -------------------------------------------------------------------------------- 1 | package xml 2 | 3 | import ( 4 | "encoding/xml" 5 | 6 | "go-micro.dev/v5/config/encoder" 7 | ) 8 | 9 | type xmlEncoder struct{} 10 | 11 | func (x xmlEncoder) Encode(v interface{}) ([]byte, error) { 12 | return xml.Marshal(v) 13 | } 14 | 15 | func (x xmlEncoder) Decode(d []byte, v interface{}) error { 16 | return xml.Unmarshal(d, v) 17 | } 18 | 19 | func (x xmlEncoder) String() string { 20 | return "xml" 21 | } 22 | 23 | func NewEncoder() encoder.Encoder { 24 | return xmlEncoder{} 25 | } 26 | -------------------------------------------------------------------------------- /v5/config/encoder/yaml/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/micro/plugins/v5/config/encoder/yaml 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/ghodss/yaml v1.0.0 7 | go-micro.dev/v5 v5.2.0 8 | ) 9 | 10 | require ( 11 | github.com/kr/text v0.2.0 // indirect 12 | github.com/rogpeppe/go-internal v1.12.0 // indirect 13 | gopkg.in/yaml.v2 v2.4.0 // indirect 14 | ) 15 | -------------------------------------------------------------------------------- /v5/config/encoder/yaml/yaml.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | import ( 4 | "github.com/ghodss/yaml" 5 | "go-micro.dev/v5/config/encoder" 6 | ) 7 | 8 | type yamlEncoder struct{} 9 | 10 | func (y yamlEncoder) Encode(v interface{}) ([]byte, error) { 11 | return yaml.Marshal(v) 12 | } 13 | 14 | func (y yamlEncoder) Decode(d []byte, v interface{}) error { 15 | return yaml.Unmarshal(d, v) 16 | } 17 | 18 | func (y yamlEncoder) String() string { 19 | return "yaml" 20 | } 21 | 22 | func NewEncoder() encoder.Encoder { 23 | return yamlEncoder{} 24 | } 25 | -------------------------------------------------------------------------------- /v5/config/source/configmap/testdata/config: -------------------------------------------------------------------------------- 1 | host=0.0.0.0 2 | port=1337 -------------------------------------------------------------------------------- /v5/config/source/configmap/testdata/config 2: -------------------------------------------------------------------------------- 1 | host=0.0.0.0 2 | port=1337 -------------------------------------------------------------------------------- /v5/config/source/configmap/testdata/mongodb: -------------------------------------------------------------------------------- 1 | host=127.0.0.1 2 | port=27017 3 | user=user 4 | password=password -------------------------------------------------------------------------------- /v5/config/source/configmap/testdata/mongodb 2: -------------------------------------------------------------------------------- 1 | host=127.0.0.1 2 | port=27017 3 | user=user 4 | password=password -------------------------------------------------------------------------------- /v5/config/source/configmap/testdata/redis: -------------------------------------------------------------------------------- 1 | url=redis://127.0.0.1:6379/db01 -------------------------------------------------------------------------------- /v5/config/source/configmap/testdata/redis 2: -------------------------------------------------------------------------------- 1 | url=redis://127.0.0.1:6379/db01 -------------------------------------------------------------------------------- /v5/config/source/grpc/proto/grpc.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | service Source { 4 | rpc Read(ReadRequest) returns (ReadResponse) {}; 5 | rpc Watch(WatchRequest) returns (stream WatchResponse) {}; 6 | } 7 | 8 | message ChangeSet { 9 | bytes data = 1; 10 | string checksum = 2; 11 | string format = 3; 12 | string source = 4; 13 | int64 timestamp = 5; 14 | } 15 | 16 | message ReadRequest { 17 | string path = 1; 18 | } 19 | 20 | message ReadResponse { 21 | ChangeSet change_set = 1; 22 | } 23 | 24 | message WatchRequest { 25 | string path = 1; 26 | } 27 | 28 | message WatchResponse { 29 | ChangeSet change_set = 1; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /v5/config/source/grpc/util.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | "time" 5 | 6 | proto "github.com/micro/plugins/v5/config/source/grpc/proto" 7 | "go-micro.dev/v5/config/source" 8 | ) 9 | 10 | func toChangeSet(c *proto.ChangeSet) *source.ChangeSet { 11 | return &source.ChangeSet{ 12 | Data: c.Data, 13 | Checksum: c.Checksum, 14 | Format: c.Format, 15 | Timestamp: time.Unix(c.Timestamp, 0), 16 | Source: c.Source, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v5/config/source/grpc/watcher.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | proto "github.com/micro/plugins/v5/config/source/grpc/proto" 5 | "go-micro.dev/v5/config/source" 6 | ) 7 | 8 | type watcher struct { 9 | stream proto.Source_WatchClient 10 | } 11 | 12 | func newWatcher(stream proto.Source_WatchClient) (*watcher, error) { 13 | return &watcher{ 14 | stream: stream, 15 | }, nil 16 | } 17 | 18 | func (w *watcher) Next() (*source.ChangeSet, error) { 19 | rsp, err := w.stream.Recv() 20 | if err != nil { 21 | return nil, err 22 | } 23 | return toChangeSet(rsp.ChangeSet), nil 24 | } 25 | 26 | func (w *watcher) Stop() error { 27 | return w.stream.CloseSend() 28 | } 29 | -------------------------------------------------------------------------------- /v5/config/source/mucp/proto/mucp.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | service Source { 4 | rpc Read(ReadRequest) returns (ReadResponse) {}; 5 | rpc Watch(WatchRequest) returns (stream WatchResponse) {}; 6 | } 7 | 8 | message ChangeSet { 9 | bytes data = 1; 10 | string checksum = 2; 11 | string format = 3; 12 | string source = 4; 13 | int64 timestamp = 5; 14 | } 15 | 16 | message ReadRequest { 17 | string path = 1; 18 | } 19 | 20 | message ReadResponse { 21 | ChangeSet change_set = 1; 22 | } 23 | 24 | message WatchRequest { 25 | string path = 1; 26 | } 27 | 28 | message WatchResponse { 29 | ChangeSet change_set = 1; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /v5/config/source/mucp/util.go: -------------------------------------------------------------------------------- 1 | package mucp 2 | 3 | import ( 4 | "time" 5 | 6 | proto "github.com/micro/plugins/v5/config/source/mucp/proto" 7 | "go-micro.dev/v5/config/source" 8 | ) 9 | 10 | func toChangeSet(c *proto.ChangeSet) *source.ChangeSet { 11 | return &source.ChangeSet{ 12 | Data: c.Data, 13 | Checksum: c.Checksum, 14 | Format: c.Format, 15 | Timestamp: time.Unix(c.Timestamp, 0), 16 | Source: c.Source, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v5/config/source/pkger/README.md: -------------------------------------------------------------------------------- 1 | # pkger 2 | 3 | pkger plugin for `go-config` 4 | 5 | ### Prerequisites 6 | 7 | > Install `pkger` cli 8 | 9 | ```bash 10 | go install github.com/markbates/pkger/cmd/pkger 11 | pkger -h 12 | ``` 13 | 14 | ### Packager 15 | 16 | > generating `pkged.go` with all files in `/config` as part of build pipeline 17 | 18 | ```bash 19 | pkger -o srv/greeter -include /config 20 | ``` 21 | 22 | ### Usage 23 | 24 | ```go 25 | if err := config.Load( 26 | pkger.NewSource(pkger.WithPath("/config/config.yaml")), 27 | ); err != nil { 28 | log.Fatal(err.Error()) 29 | } 30 | ``` 31 | -------------------------------------------------------------------------------- /v5/config/source/pkger/format.go: -------------------------------------------------------------------------------- 1 | package pkger 2 | 3 | import ( 4 | "strings" 5 | 6 | "go-micro.dev/v5/config/encoder" 7 | ) 8 | 9 | func format(p string, e encoder.Encoder) string { 10 | parts := strings.Split(p, ".") 11 | if len(parts) > 1 { 12 | return parts[len(parts)-1] 13 | } 14 | return e.String() 15 | } 16 | -------------------------------------------------------------------------------- /v5/config/source/pkger/options.go: -------------------------------------------------------------------------------- 1 | package pkger 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v5/config/source" 7 | ) 8 | 9 | type pkgerPathKey struct{} 10 | 11 | // WithPath sets the path to pkger. 12 | func WithPath(p string) source.Option { 13 | return func(o *source.Options) { 14 | if o.Context == nil { 15 | o.Context = context.Background() 16 | } 17 | o.Context = context.WithValue(o.Context, pkgerPathKey{}, p) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /v5/config/source/runtimevar/options.go: -------------------------------------------------------------------------------- 1 | package runtimevar 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v5/config/source" 7 | "gocloud.dev/runtimevar" 8 | ) 9 | 10 | type variableKey struct{} 11 | 12 | // WithVariable sets the runtimevar.Variable. 13 | func WithVariable(v *runtimevar.Variable) source.Option { 14 | return func(o *source.Options) { 15 | if o.Context == nil { 16 | o.Context = context.Background() 17 | } 18 | o.Context = context.WithValue(o.Context, variableKey{}, v) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /v5/config/source/url/format.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | func format(ct string) string { 8 | parts := strings.Split(ct, "/") 9 | if len(parts) <= 1 { 10 | return ct 11 | } 12 | return parts[1] 13 | } 14 | -------------------------------------------------------------------------------- /v5/config/source/url/format_test.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestFormat(t *testing.T) { 8 | testCases := []struct { 9 | contentType string 10 | format string 11 | }{ 12 | {"application/json", "json"}, 13 | {"application/xml", "xml"}, 14 | {"application/json", "json"}, 15 | } 16 | 17 | for _, c := range testCases { 18 | f := format(c.contentType) 19 | if f != c.format { 20 | t.Fatalf("failed to format %s: expected %s got %s", c.contentType, c.format, f) 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /v5/config/source/url/options.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v5/config/source" 7 | ) 8 | 9 | type urlKey struct{} 10 | 11 | func WithURL(u string) source.Option { 12 | return func(o *source.Options) { 13 | if o.Context == nil { 14 | o.Context = context.Background() 15 | } 16 | o.Context = context.WithValue(o.Context, urlKey{}, u) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v5/config/source/url/watcher.go: -------------------------------------------------------------------------------- 1 | package url 2 | 3 | import ( 4 | "errors" 5 | 6 | "go-micro.dev/v5/config/source" 7 | ) 8 | 9 | type urlWatcher struct { 10 | u *urlSource 11 | exit chan bool 12 | } 13 | 14 | func newWatcher(u *urlSource) (*urlWatcher, error) { 15 | return &urlWatcher{ 16 | u: u, 17 | exit: make(chan bool), 18 | }, nil 19 | } 20 | 21 | func (u *urlWatcher) Next() (*source.ChangeSet, error) { 22 | <-u.exit 23 | return nil, errors.New("url watcher stopped") 24 | } 25 | 26 | func (u *urlWatcher) Stop() error { 27 | select { 28 | case <-u.exit: 29 | default: 30 | } 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /v5/config/source/vault/testdata/vault_init_commands: -------------------------------------------------------------------------------- 1 | vault kv put secret/data/db/auth user=myuser password=mypassword2 host=128.23.33.21 port=3307 -------------------------------------------------------------------------------- /v5/config/source/vault/testdata/vault_init_commands 2: -------------------------------------------------------------------------------- 1 | vault kv put secret/data/db/auth user=myuser password=mypassword2 host=128.23.33.21 port=3307 -------------------------------------------------------------------------------- /v5/config/source/vault/watcher.go: -------------------------------------------------------------------------------- 1 | package vault 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/hashicorp/vault/api" 7 | "go-micro.dev/v5/config/source" 8 | ) 9 | 10 | type watcher struct { 11 | c *api.Client 12 | exit chan bool 13 | } 14 | 15 | func newWatcher(c *api.Client) *watcher { 16 | return &watcher{ 17 | c: c, 18 | exit: make(chan bool), 19 | } 20 | } 21 | 22 | func (w *watcher) Next() (*source.ChangeSet, error) { 23 | <-w.exit 24 | return nil, errors.New("url watcher stopped") 25 | } 26 | 27 | func (w *watcher) Stop() error { 28 | select { 29 | case <-w.exit: 30 | default: 31 | } 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /v5/logger/apex/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/micro/plugins/v5/logger/apex 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/apex/log v1.9.0 7 | go-micro.dev/v5 v5.2.0 8 | ) 9 | 10 | require ( 11 | github.com/fatih/color v1.9.0 // indirect 12 | github.com/google/uuid v1.3.0 // indirect 13 | github.com/mattn/go-colorable v0.1.8 // indirect 14 | github.com/mattn/go-isatty v0.0.16 // indirect 15 | github.com/pkg/errors v0.9.1 // indirect 16 | golang.org/x/sys v0.18.0 // indirect 17 | ) 18 | -------------------------------------------------------------------------------- /v5/logger/logrus/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/micro/plugins/v5/logger/logrus 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/sirupsen/logrus v1.9.0 7 | go-micro.dev/v5 v5.2.0 8 | ) 9 | 10 | require ( 11 | github.com/google/uuid v1.3.0 // indirect 12 | golang.org/x/sys v0.18.0 // indirect 13 | ) 14 | -------------------------------------------------------------------------------- /v5/logger/windowseventlog/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/micro/plugins/v5/logger/windowseventlog 2 | 3 | go 1.17 4 | 5 | require ( 6 | github.com/stretchr/testify v1.8.1 7 | go-micro.dev/v5 v5.2.0 8 | golang.org/x/sys v0.18.0 9 | ) 10 | 11 | require ( 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/google/uuid v1.3.0 // indirect 14 | github.com/kr/text v0.2.0 // indirect 15 | github.com/pmezard/go-difflib v1.0.0 // indirect 16 | github.com/rogpeppe/go-internal v1.12.0 // indirect 17 | gopkg.in/yaml.v3 v3.0.1 // indirect 18 | ) 19 | -------------------------------------------------------------------------------- /v5/logger/windowseventlog/options.go: -------------------------------------------------------------------------------- 1 | //go:build windows 2 | // +build windows 3 | 4 | package windowseventlog 5 | 6 | import "go-micro.dev/v5/logger" 7 | 8 | type src struct{} 9 | type eid struct{} 10 | 11 | type Options struct { 12 | logger.Options 13 | Src string 14 | Eid uint32 15 | } 16 | 17 | func WithSrc(namesrc string) logger.Option { 18 | return logger.SetOption(src{}, namesrc) 19 | } 20 | 21 | func WithEid(neweid uint32) logger.Option { 22 | return logger.SetOption(eid{}, neweid) 23 | } 24 | -------------------------------------------------------------------------------- /v5/logger/zap/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/micro/plugins/v5/logger/zap 2 | 3 | go 1.17 4 | 5 | require ( 6 | go-micro.dev/v5 v5.2.0 7 | go.uber.org/zap v1.23.0 8 | ) 9 | 10 | require ( 11 | github.com/google/uuid v1.3.0 // indirect 12 | go.uber.org/atomic v1.10.0 // indirect 13 | go.uber.org/goleak v1.1.12 // indirect 14 | go.uber.org/multierr v1.8.0 // indirect 15 | ) 16 | -------------------------------------------------------------------------------- /v5/logger/zerolog/README.md: -------------------------------------------------------------------------------- 1 | # Zerolog 2 | 3 | [Zerolog](https://github.com/rs/zerolog) logger implementation for __go-micro__ [meta logger](https://github.com/micro/go-micro/tree/master/logger). 4 | 5 | ## Usage 6 | 7 | ```go 8 | func ExampleWithOut() { 9 | logger.DefaultLogger = zerolog.NewLogger(logger.WithOutput(os.Stdout), logger.WithLevel(logger.DebugLevel)) 10 | 11 | logger.Infof(logger.InfoLevel, "testing: %s", "Infof") 12 | 13 | // Output: 14 | // {"level":"info","message":"testing: Infof"} 15 | } 16 | ``` 17 | -------------------------------------------------------------------------------- /v5/registry/cache/cache.go: -------------------------------------------------------------------------------- 1 | // Package cache provides a registry cache 2 | package cache 3 | 4 | import ( 5 | "go-micro.dev/v5/registry" 6 | "go-micro.dev/v5/registry/cache" 7 | ) 8 | 9 | // New returns a new cache. 10 | func New(r registry.Registry, opts ...cache.Option) cache.Cache { 11 | return cache.New(r, opts...) 12 | } 13 | -------------------------------------------------------------------------------- /v5/registry/cache/options.go: -------------------------------------------------------------------------------- 1 | package cache 2 | 3 | import ( 4 | "time" 5 | 6 | "go-micro.dev/v5/registry/cache" 7 | ) 8 | 9 | // WithTTL sets the cache TTL. 10 | func WithTTL(t time.Duration) cache.Option { 11 | return cache.WithTTL(t) 12 | } 13 | -------------------------------------------------------------------------------- /v5/registry/gossip/README.md: -------------------------------------------------------------------------------- 1 | # Gossip Registry 2 | 3 | Gossip is a zero dependency registry which uses github.com/hashicorp/memberlist to broadcast registry information 4 | via the SWIM protocol. 5 | 6 | ## Usage 7 | 8 | Start with the registry flag or env var 9 | 10 | ```bash 11 | MICRO_REGISTRY=gossip go run service.go 12 | ``` 13 | 14 | On startup you'll see something like 15 | 16 | ```bash 17 | 2018/12/06 18:17:48 Registry Listening on 192.168.1.65:56390 18 | ``` 19 | 20 | To join this gossip ring set the registry address using flag or env var 21 | 22 | ```bash 23 | MICRO_REGISTRY_ADDRESS=192.168.1.65:56390 24 | ``` 25 | -------------------------------------------------------------------------------- /v5/registry/gossip/proto/gossip.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package gossip; 4 | 5 | // Update is the message broadcast 6 | message Update { 7 | // time to live for entry 8 | uint64 expires = 1; 9 | // type of update 10 | int32 type = 2; 11 | // what action is taken 12 | int32 action = 3; 13 | // any other associated metadata about the data 14 | map metadata = 6; 15 | // the payload data; 16 | bytes data = 7; 17 | } 18 | -------------------------------------------------------------------------------- /v5/registry/mdns/mdns.go: -------------------------------------------------------------------------------- 1 | // Package mdns provides a multicast dns registry 2 | package mdns 3 | 4 | import ( 5 | "go-micro.dev/v5/registry" 6 | "go-micro.dev/v5/cmd" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultRegistries["mdns"] = NewRegistry 11 | } 12 | 13 | // NewRegistry returns a new mdns registry. 14 | func NewRegistry(opts ...registry.Option) registry.Registry { 15 | return registry.NewRegistry(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v5/registry/memory/memory_watcher.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | import ( 4 | "errors" 5 | 6 | "go-micro.dev/v5/registry" 7 | ) 8 | 9 | type memoryWatcher struct { 10 | exit chan bool 11 | opts registry.WatchOptions 12 | } 13 | 14 | func (m *memoryWatcher) Next() (*registry.Result, error) { 15 | // not implement so we just block until exit 16 | <-m.exit 17 | return nil, errors.New("watcher stopped") 18 | } 19 | 20 | func (m *memoryWatcher) Stop() { 21 | select { 22 | case <-m.exit: 23 | return 24 | default: 25 | close(m.exit) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /v5/registry/memory/watcher_test.go: -------------------------------------------------------------------------------- 1 | package memory 2 | 3 | import ( 4 | "testing" 5 | 6 | "go-micro.dev/v5/registry" 7 | ) 8 | 9 | func TestWatcher(t *testing.T) { 10 | w := &Watcher{ 11 | id: "test", 12 | res: make(chan *registry.Result), 13 | exit: make(chan bool), 14 | } 15 | 16 | go func() { 17 | w.res <- ®istry.Result{} 18 | }() 19 | 20 | _, err := w.Next() 21 | if err != nil { 22 | t.Fatal("unexpected err", err) 23 | } 24 | 25 | w.Stop() 26 | 27 | if _, err := w.Next(); err == nil { 28 | t.Fatal("expected error on Next()") 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /v5/registry/nats/assert_test.go: -------------------------------------------------------------------------------- 1 | package nats_test 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func assertNoError(tb testing.TB, actual error) { 9 | if actual != nil { 10 | tb.Errorf("expected no error, got %v", actual) 11 | } 12 | } 13 | 14 | func assertEqual(tb testing.TB, expected, actual interface{}) { 15 | if !reflect.DeepEqual(expected, actual) { 16 | tb.Errorf("expected %v, got %v", expected, actual) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v5/registry/proxy/README.md: -------------------------------------------------------------------------------- 1 | # Proxy Registry 2 | 3 | This is a registry plugin for the micro [proxy](https://micro.mu/docs/proxy.html) 4 | 5 | ## Usage 6 | 7 | Here's a simple usage guide 8 | 9 | ### Run Proxy 10 | 11 | ``` 12 | # download 13 | go get github.com/micro/micro 14 | 15 | # run 16 | micro proxy 17 | ``` 18 | 19 | ### Import and Flag plugin 20 | 21 | ```go 22 | import _ "github.com/micro/plugins/v5/registry/proxy" 23 | ``` 24 | 25 | ``` 26 | go run main.go --registry=proxy 27 | ``` 28 | -------------------------------------------------------------------------------- /v5/selector/label/README.md: -------------------------------------------------------------------------------- 1 | # Label Selector 2 | 3 | The label selecotr is a a priority based label selector. Rather than just returning nodes with specific labels 4 | this selector orders the nodes based on a list of labels. If no labels match all the nodes are still returned. 5 | The priority based label selector is useful for such things as rudimentary AZ based routing where requests made 6 | to other services should remain in the same AZ. 7 | -------------------------------------------------------------------------------- /v5/selector/label/options.go: -------------------------------------------------------------------------------- 1 | package label 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v5/selector" 7 | ) 8 | 9 | type labelKey struct{} 10 | 11 | type label struct { 12 | key string 13 | val string 14 | } 15 | 16 | // Label used in the priority label list. 17 | func Label(k, v string) selector.Option { 18 | return func(o *selector.Options) { 19 | l, ok := o.Context.Value(labelKey{}).([]label) 20 | if !ok { 21 | l = []label{} 22 | } 23 | l = append(l, label{k, v}) 24 | o.Context = context.WithValue(o.Context, labelKey{}, l) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /v5/selector/registry/options.go: -------------------------------------------------------------------------------- 1 | package registry 2 | 3 | import ( 4 | "context" 5 | "time" 6 | 7 | "go-micro.dev/v5/selector" 8 | ) 9 | 10 | // Set the registry cache ttl. 11 | func TTL(t time.Duration) selector.Option { 12 | return func(o *selector.Options) { 13 | if o.Context == nil { 14 | o.Context = context.Background() 15 | } 16 | o.Context = context.WithValue(o.Context, "selector_ttl", t) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v5/selector/registry/registry.go: -------------------------------------------------------------------------------- 1 | // Package registry uses the go-micro registry for selection 2 | package registry 3 | 4 | import ( 5 | "go-micro.dev/v5/selector" 6 | "go-micro.dev/v5/cmd" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultSelectors["registry"] = NewSelector 11 | } 12 | 13 | // NewSelector returns a new registry selector. 14 | func NewSelector(opts ...selector.Option) selector.Selector { 15 | return selector.NewSelector(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v5/server/grpc/context.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v5/server" 7 | ) 8 | 9 | func setServerOption(k, v interface{}) server.Option { 10 | return func(o *server.Options) { 11 | if o.Context == nil { 12 | o.Context = context.Background() 13 | } 14 | o.Context = context.WithValue(o.Context, k, v) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /v5/server/grpc/response.go: -------------------------------------------------------------------------------- 1 | package grpc 2 | 3 | import ( 4 | "go-micro.dev/v5/codec" 5 | ) 6 | 7 | type rpcResponse struct { 8 | header map[string]string 9 | codec codec.Codec 10 | } 11 | 12 | func (r *rpcResponse) Codec() codec.Writer { 13 | return r.codec 14 | } 15 | 16 | func (r *rpcResponse) WriteHeader(hdr map[string]string) { 17 | for k, v := range hdr { 18 | r.header[k] = v 19 | } 20 | } 21 | 22 | func (r *rpcResponse) Write(b []byte) error { 23 | return r.codec.Write(&codec.Message{ 24 | Header: r.header, 25 | Body: b, 26 | }, nil) 27 | } 28 | -------------------------------------------------------------------------------- /v5/server/http/buffer.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type buffer struct { 8 | *bytes.Buffer 9 | } 10 | 11 | func (b *buffer) Close() error { 12 | b.Buffer.Reset() 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /v5/server/http/context.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v5/server" 7 | ) 8 | 9 | func setServerOption(k, v interface{}) server.Option { 10 | return func(o *server.Options) { 11 | if o.Context == nil { 12 | o.Context = context.Background() 13 | } 14 | o.Context = context.WithValue(o.Context, k, v) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /v5/server/http/handler.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "go-micro.dev/v5/registry" 5 | "go-micro.dev/v5/server" 6 | ) 7 | 8 | type httpHandler struct { 9 | opts server.HandlerOptions 10 | eps []*registry.Endpoint 11 | hd interface{} 12 | } 13 | 14 | func (h *httpHandler) Name() string { 15 | return "handler" 16 | } 17 | 18 | func (h *httpHandler) Handler() interface{} { 19 | return h.hd 20 | } 21 | 22 | func (h *httpHandler) Endpoints() []*registry.Endpoint { 23 | return h.eps 24 | } 25 | 26 | func (h *httpHandler) Options() server.HandlerOptions { 27 | return h.opts 28 | } 29 | -------------------------------------------------------------------------------- /v5/server/mucp/mucp.go: -------------------------------------------------------------------------------- 1 | // Package mucp provides an mucp server 2 | package mucp 3 | 4 | import ( 5 | "go-micro.dev/v5/server" 6 | "go-micro.dev/v5/cmd" 7 | ) 8 | 9 | func init() { 10 | cmd.DefaultServers["mucp"] = NewServer 11 | } 12 | 13 | // NewServer returns a micro server interface. 14 | func NewServer(opts ...server.Option) server.Server { 15 | return server.NewServer(opts...) 16 | } 17 | -------------------------------------------------------------------------------- /v5/store/file/options.go: -------------------------------------------------------------------------------- 1 | package file 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v5/store" 7 | ) 8 | 9 | type dirOptionKey struct{} 10 | 11 | // DirOption is a file store Option to set the directory for the file store. 12 | func DirOption(dir string) store.Option { 13 | return func(o *store.Options) { 14 | if o.Context == nil { 15 | o.Context = context.Background() 16 | } 17 | o.Context = context.WithValue(o.Context, dirOptionKey{}, dir) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /v5/store/nats-js-kv/context.go: -------------------------------------------------------------------------------- 1 | package natsjskv 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v5/store" 7 | ) 8 | 9 | // setStoreOption returns a function to setup a context with given value. 10 | func setStoreOption(k, v interface{}) store.Option { 11 | return func(o *store.Options) { 12 | if o.Context == nil { 13 | o.Context = context.Background() 14 | } 15 | 16 | o.Context = context.WithValue(o.Context, k, v) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /v5/store/nats-js/context.go: -------------------------------------------------------------------------------- 1 | package natsjs 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v5/store" 7 | ) 8 | 9 | // setStoreOption returns a function to setup a context with given value. 10 | func setStoreOption(k, v interface{}) store.Option { 11 | return func(o *store.Options) { 12 | if o.Context == nil { 13 | o.Context = context.Background() 14 | } 15 | o.Context = context.WithValue(o.Context, k, v) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /v5/transport/grpc/proto/transport.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package go.micro.transport.grpc; 4 | 5 | service Transport { 6 | rpc Stream(stream Message) returns (stream Message) {} 7 | } 8 | 9 | message Message { 10 | map header = 1; 11 | bytes body = 2; 12 | } 13 | -------------------------------------------------------------------------------- /v5/transport/http/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/micro/plugins/v5/transport/http 2 | 3 | go 1.17 4 | 5 | require go-micro.dev/v5 v5.2.0 6 | 7 | require ( 8 | github.com/google/uuid v1.3.0 // indirect 9 | github.com/pkg/errors v0.9.1 // indirect 10 | golang.org/x/net v0.23.0 // indirect 11 | golang.org/x/text v0.14.0 // indirect 12 | ) 13 | -------------------------------------------------------------------------------- /v5/transport/http/http.go: -------------------------------------------------------------------------------- 1 | // Package http returns a http2 transport using net/http 2 | package http 3 | 4 | import ( 5 | "go-micro.dev/v5/transport" 6 | ) 7 | 8 | // NewTransport returns a new http transport using net/http and supporting http2. 9 | func NewTransport(opts ...transport.Option) transport.Transport { 10 | return transport.NewHTTPTransport(opts...) 11 | } 12 | -------------------------------------------------------------------------------- /v5/transport/http/options.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | 7 | "go-micro.dev/v5/transport" 8 | ) 9 | 10 | // Handle registers the handler for the given pattern. 11 | func Handle(pattern string, handler http.Handler) transport.Option { 12 | return func(o *transport.Options) { 13 | if o.Context == nil { 14 | o.Context = context.Background() 15 | } 16 | handlers, ok := o.Context.Value("http_handlers").(map[string]http.Handler) 17 | if !ok { 18 | handlers = make(map[string]http.Handler) 19 | } 20 | handlers[pattern] = handler 21 | o.Context = context.WithValue(o.Context, "http_handlers", handlers) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /v5/transport/nats/options.go: -------------------------------------------------------------------------------- 1 | package nats 2 | 3 | import ( 4 | "context" 5 | 6 | "github.com/nats-io/nats.go" 7 | "go-micro.dev/v5/transport" 8 | ) 9 | 10 | type optionsKey struct{} 11 | 12 | // Options allow to inject a nats.Options struct for configuring 13 | // the nats connection. 14 | func Options(nopts nats.Options) transport.Option { 15 | return func(o *transport.Options) { 16 | if o.Context == nil { 17 | o.Context = context.Background() 18 | } 19 | o.Context = context.WithValue(o.Context, optionsKey{}, nopts) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /v5/transport/utp/README.md: -------------------------------------------------------------------------------- 1 | # uTP Transport 2 | 3 | The uTP transport is a go-micro transport which makes use of github.com/anacrolix/utp 4 | 5 | uTP is the [Micro Transport Protocol](https://en.wikipedia.org/wiki/Micro_Transport_Protocol) an 6 | open UDP variant of the BitTorrent protocol. 7 | 8 | 9 | The uTP transport in combination with STUN allows for peer to peer communication. 10 | -------------------------------------------------------------------------------- /v5/wrapper/select/roundrobin/README.md: -------------------------------------------------------------------------------- 1 | # Round Robin Wrapper 2 | 3 | The round robin wrapper is a stateful client wrapper which gives you a true round robin strategy for the selector 4 | 5 | ## Usage 6 | 7 | Pass in the wrapper when you create your service 8 | 9 | ``` 10 | wrapper := roundrobin.NewClientWrapper() 11 | 12 | service := micro.NewService( 13 | micro.Name("foo"), 14 | micro.WrapClient(wrapper), 15 | ) 16 | ``` 17 | -------------------------------------------------------------------------------- /v5/wrapper/select/version/README.md: -------------------------------------------------------------------------------- 1 | # Version Wrapper 2 | 3 | The version wrapper is a stateful client wrapper which gives you a ability to select only latest version services. That suitable for easy upgrade running services without downtime. 4 | 5 | ## Usage 6 | 7 | Pass in the wrapper when you create your service 8 | 9 | ``` 10 | wrapper := version.NewClientWrapper() 11 | 12 | service := micro.NewService( 13 | micro.Name("foo"), 14 | micro.WrapClient(wrapper), 15 | ) 16 | ``` 17 | -------------------------------------------------------------------------------- /v5/wrapper/trace/awsxray/awsxray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/go-micro/plugins/be3f35ce64647f8712cd0578b1e27c879467cb71/v5/wrapper/trace/awsxray/awsxray.png -------------------------------------------------------------------------------- /v5/wrapper/trace/datadog/ext.go: -------------------------------------------------------------------------------- 1 | package datadog 2 | 3 | const ( 4 | // tagendpoint = "micro.endpoint" 5 | // tagservice = "micro.service" 6 | // tagMethod = "micro.method". 7 | tagStatus = "micro.status" 8 | tagRole = "micro.role" 9 | tagID = "micro.id" 10 | tagVersion = "micro.version" 11 | ) 12 | -------------------------------------------------------------------------------- /v5/wrapper/trace/datadog/stats.go: -------------------------------------------------------------------------------- 1 | package datadog 2 | 3 | // TODO: add statd 4 | // https://github.com/DataDog/datadog-go/tree/master/statsd 5 | 6 | // StatsProfile groups metrics-related data. 7 | type StatsProfile struct { 8 | Role string 9 | } 10 | 11 | var ( 12 | // ClientProfile is used for RPC clients. 13 | ClientProfile = &StatsProfile{ 14 | Role: "micro.client", 15 | } 16 | 17 | // ServerProfile is used for RPC servers. 18 | ServerProfile = &StatsProfile{ 19 | Role: "micro.server", 20 | } 21 | ) 22 | -------------------------------------------------------------------------------- /v5/wrapper/trace/datadog/status.go: -------------------------------------------------------------------------------- 1 | package datadog 2 | 3 | import ( 4 | "google.golang.org/grpc/codes" 5 | ) 6 | 7 | var microCodeToStatusCode = map[int32]codes.Code{ 8 | 400: codes.InvalidArgument, 9 | 401: codes.Unauthenticated, 10 | 403: codes.PermissionDenied, 11 | 404: codes.NotFound, 12 | 409: codes.Aborted, 13 | 500: codes.Internal, 14 | } 15 | -------------------------------------------------------------------------------- /v5/wrapper/trace/opentelemetry/README.md: -------------------------------------------------------------------------------- 1 | # OpenTelemetry wrappers 2 | 3 | OpenTelemetry wrappers propagate traces (spans) accross services. 4 | 5 | ## Usage 6 | 7 | ```go 8 | service := micro.NewService( 9 | micro.Name("go.micro.srv.greeter"), 10 | micro.WrapClient(opentelemetry.NewClientWrapper()), 11 | micro.WrapHandler(open.NewHandlerWrapper()), 12 | micro.WrapSubscriber(opentelemetry.NewSubscriberWrapper()), 13 | ) 14 | ``` -------------------------------------------------------------------------------- /v5/wrapper/validator/validator.go: -------------------------------------------------------------------------------- 1 | package validator 2 | 3 | import ( 4 | "context" 5 | 6 | "go-micro.dev/v5/errors" 7 | "go-micro.dev/v5/server" 8 | ) 9 | 10 | type Validator interface { 11 | Validate() error 12 | } 13 | 14 | func NewHandlerWrapper() server.HandlerWrapper { 15 | return func(fn server.HandlerFunc) server.HandlerFunc { 16 | return func(ctx context.Context, req server.Request, rsp interface{}) error { 17 | if v, ok := req.Body().(Validator); ok { 18 | if err := v.Validate(); err != nil { 19 | return errors.BadRequest(req.Service(), "%v", err) 20 | } 21 | } 22 | return fn(ctx, req, rsp) 23 | } 24 | } 25 | } 26 | --------------------------------------------------------------------------------