├── .asf.yaml ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.md │ └── enhancement.md ├── dependabot.yml ├── release-drafter.yml └── workflows │ ├── codeql-analysis.yml │ ├── github-actions.yml │ ├── golangci-lint.yml │ └── release-drafter.yml ├── .gitignore ├── .gitmodules ├── .golangci.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── NOTICE ├── README.md ├── client ├── action.go ├── client.go ├── compat.go ├── options.go └── options_test.go ├── cluster ├── cluster │ ├── adaptivesvc │ │ ├── cluster.go │ │ ├── cluster_invoker.go │ │ └── doc.go │ ├── available │ │ ├── cluster.go │ │ ├── cluster_invoker.go │ │ ├── cluster_invoker_test.go │ │ └── doc.go │ ├── base │ │ ├── cluster_invoker.go │ │ └── cluster_invoker_test.go │ ├── broadcast │ │ ├── cluster.go │ │ ├── cluster_invoker.go │ │ ├── cluster_invoker_test.go │ │ └── doc.go │ ├── cluster.go │ ├── cluster_interceptor.go │ ├── failback │ │ ├── cluster.go │ │ ├── cluster_invoker.go │ │ ├── cluster_test.go │ │ └── doc.go │ ├── failfast │ │ ├── cluster.go │ │ ├── cluster_invoker.go │ │ ├── cluster_test.go │ │ └── doc.go │ ├── failover │ │ ├── cluster.go │ │ ├── cluster_invoker.go │ │ ├── cluster_test.go │ │ └── doc.go │ ├── failsafe │ │ ├── cluster.go │ │ ├── cluster_invoker.go │ │ ├── cluster_test.go │ │ └── doc.go │ ├── forking │ │ ├── cluster.go │ │ ├── cluster_invoker.go │ │ ├── cluster_test.go │ │ └── doc.go │ ├── interceptor_invoker.go │ ├── mock.go │ └── zoneaware │ │ ├── cluster.go │ │ ├── cluster_interceptor.go │ │ ├── cluster_invoker.go │ │ ├── cluster_invoker_test.go │ │ └── doc.go ├── cluster_impl │ └── import.go ├── directory │ ├── base │ │ ├── directory.go │ │ └── directory_test.go │ ├── directory.go │ └── static │ │ ├── directory.go │ │ └── directory_test.go ├── loadbalance │ ├── aliasmethod │ │ ├── alias_method.go │ │ ├── doc.go │ │ ├── loadbalance.go │ │ └── loadbalance_test.go │ ├── consistenthashing │ │ ├── doc.go │ │ ├── loadbalance.go │ │ ├── loadbalance_test.go │ │ └── selector.go │ ├── iwrr │ │ ├── doc.go │ │ ├── iwrr.go │ │ ├── loadbalance.go │ │ └── loadbalance_test.go │ ├── leastactive │ │ ├── doc.go │ │ ├── loadbalance.go │ │ └── loadbalance_test.go │ ├── loadbalance.go │ ├── loadbalance_benchmarks_test.go │ ├── p2c │ │ ├── doc.go │ │ ├── loadbalance.go │ │ └── loadbalance_test.go │ ├── random │ │ ├── doc.go │ │ ├── loadbalance.go │ │ └── loadbalance_test.go │ ├── roundrobin │ │ ├── doc.go │ │ ├── loadbalance.go │ │ └── loadbalance_test.go │ └── util.go ├── metrics │ ├── constants.go │ ├── local_metrics.go │ ├── metrics.go │ ├── mock_metrics.go │ └── utils.go ├── router │ ├── affinity │ │ ├── factory.go │ │ ├── router.go │ │ └── router_test.go │ ├── chain.go │ ├── chain │ │ └── chain.go │ ├── condition │ │ ├── dynamic_router.go │ │ ├── factory.go │ │ ├── matcher │ │ │ ├── argument.go │ │ │ ├── attachment.go │ │ │ ├── base.go │ │ │ ├── extension.go │ │ │ ├── factory.go │ │ │ ├── matcher.go │ │ │ ├── param.go │ │ │ └── pattern_value │ │ │ │ ├── extension.go │ │ │ │ ├── pattern.go │ │ │ │ ├── scope.go │ │ │ │ └── wildcard.go │ │ ├── route.go │ │ └── router_test.go │ ├── polaris │ │ ├── default.go │ │ ├── factory.go │ │ └── router.go │ ├── router.go │ ├── script │ │ ├── factory.go │ │ ├── instance │ │ │ ├── instances_pool.go │ │ │ ├── js_instance.go │ │ │ └── js_instance_test.go │ │ ├── router.go │ │ └── router_test.go │ └── tag │ │ ├── factory.go │ │ ├── match.go │ │ ├── router.go │ │ └── router_test.go └── utils │ ├── adaptivesvc.go │ └── version.go ├── common ├── config │ ├── environment.go │ ├── environment_test.go │ └── utils.go ├── constant │ ├── cluster.go │ ├── default.go │ ├── env.go │ ├── file │ │ └── suffix.go │ ├── key.go │ ├── loadbalance.go │ ├── metric.go │ ├── otel.go │ ├── polaris_key.go │ ├── serialization.go │ ├── time.go │ ├── version.go │ └── xds.go ├── doc.go ├── dubboutil │ ├── case_invert.go │ └── copier.go ├── extension │ ├── auth.go │ ├── cluster.go │ ├── config.go │ ├── config_center.go │ ├── config_center_factory.go │ ├── config_post_processor.go │ ├── config_reader.go │ ├── configurator.go │ ├── filter.go │ ├── graceful_shutdown.go │ ├── loadbalance.go │ ├── logger.go │ ├── metadata_report_factory.go │ ├── otel_trace.go │ ├── protocol.go │ ├── proxy_factory.go │ ├── registry.go │ ├── registry_directory.go │ ├── rest_client.go │ ├── rest_server.go │ ├── router_condition_matcher.go │ ├── router_condition_pattern_value.go │ ├── router_factory.go │ ├── service_discovery.go │ ├── service_instance_customizer.go │ ├── service_instance_selector_factory.go │ ├── service_name_mapping.go │ └── tps_limit.go ├── host_util.go ├── host_util_test.go ├── match.go ├── node.go ├── rpc_service.go ├── rpc_service_test.go ├── url.go └── url_test.go ├── compat.go ├── config ├── application_config.go ├── application_config_test.go ├── config_center_config.go ├── config_loader.go ├── config_loader_options.go ├── config_loader_options_test.go ├── config_resolver.go ├── config_resolver_test.go ├── config_setter.go ├── config_utils.go ├── config_utils_test.go ├── consumer_config.go ├── custom_config.go ├── custom_config_test.go ├── doc.go ├── generic │ ├── generic_service.go │ └── generic_service_test.go ├── graceful_shutdown.go ├── graceful_shutdown_config.go ├── graceful_shutdown_config_test.go ├── graceful_shutdown_signal_darwin.go ├── graceful_shutdown_signal_linux.go ├── graceful_shutdown_signal_windows.go ├── graceful_shutdown_test.go ├── interfaces │ ├── config_post_processor.go │ └── config_reader.go ├── logger_config.go ├── logger_config_test.go ├── metadata_config.go ├── metadata_config_test.go ├── method_config.go ├── metric_config.go ├── metric_config_test.go ├── mock_rpcservice.go ├── mock_rpcservice_test.go ├── options.go ├── otel_config.go ├── otel_config_test.go ├── profiles_config.go ├── profiles_config_test.go ├── protocol_config.go ├── protocol_config_test.go ├── provider_config.go ├── provider_config_test.go ├── reference_config.go ├── reference_config_test.go ├── registry_config.go ├── registry_config_test.go ├── remote_config.go ├── remote_config_test.go ├── root_config.go ├── root_config_test.go ├── router_config.go ├── router_config_test.go ├── service.go ├── service_config.go ├── service_config_test.go ├── service_discovery_config.go ├── service_discovery_config_test.go ├── service_test.go ├── ssl_config.go ├── ssl_config_test.go ├── testdata │ ├── application.yaml │ ├── config │ │ ├── active │ │ │ ├── application-local.yaml │ │ │ └── application.yaml │ │ ├── app │ │ │ └── application.yaml │ │ ├── application │ │ │ └── application.yaml │ │ ├── center │ │ │ └── conf-application.yaml │ │ ├── custom │ │ │ ├── custom.yaml │ │ │ └── empty.yaml │ │ ├── logger │ │ │ ├── empty_log.yaml │ │ │ ├── file_log.yaml │ │ │ └── log.yaml │ │ ├── properties │ │ │ └── application.properties │ │ ├── protocol │ │ │ ├── application.yaml │ │ │ └── empty_application.yaml │ │ ├── provider │ │ │ ├── application.yaml │ │ │ ├── empty_registry_application.yaml │ │ │ └── registry_application.yaml │ │ ├── registry │ │ │ ├── application.yaml │ │ │ └── empty_application.yaml │ │ └── resolver │ │ │ └── application.yaml │ ├── consumer_config.properties │ ├── consumer_config.yml │ ├── consumer_config_with_configcenter.yml │ ├── consumer_config_withoutProtocol.yml │ ├── provider_config.properties │ ├── provider_config.yml │ ├── provider_config_withoutProtocol.yml │ ├── root_config_test.yml │ ├── router_config_dest_rule.yml │ └── router_config_virtual_service.yml ├── tls_config.go ├── tls_config_test.go ├── tracing_config.go └── tracing_config_test.go ├── config_center ├── base_dynamic_configuration.go ├── configuration_listener.go ├── configurator.go ├── configurator │ ├── mock.go │ ├── override.go │ └── override_test.go ├── doc.go ├── dynamic_configuration.go ├── dynamic_configuration_factory.go ├── dynamic_configuration_test.go ├── file │ ├── doc.go │ ├── factory.go │ ├── impl.go │ ├── impl_test.go │ └── listener.go ├── mock_dynamic_config.go ├── nacos │ ├── client.go │ ├── client_test.go │ ├── doc.go │ ├── facade.go │ ├── factory.go │ ├── impl.go │ ├── impl_test.go │ └── listener.go ├── options.go ├── parser │ ├── configuration_parser.go │ └── configuration_parser_test.go └── zookeeper │ ├── doc.go │ ├── factory.go │ ├── impl.go │ └── listener.go ├── doc.go ├── doc ├── apache │ ├── apache-release-procedure-20200306.md │ └── release_note.md └── imgs │ ├── arc.png │ ├── invite.png │ ├── usecase-autohome.png │ ├── usecase-beike.png │ ├── usecase-eht.png │ ├── usecase-gaode.png │ ├── usecase-genshuixue.png │ ├── usecase-jd.png │ ├── usecase-kaikele.png │ ├── usecase-mgtv.png │ ├── usecase-mi.png │ ├── usecase-mosn.png │ ├── usecase-pdd.png │ ├── usecase-sohu.png │ ├── usecase-tianyi.png │ ├── usecase-tiger-brokers.png │ ├── usecase-tuya.png │ ├── usecase-vivo.png │ ├── usecase-xiecheng.png │ ├── usecase-zhanzhang.png │ ├── usecase-zonghengwenxue.png │ └── usecase-zto.png ├── dubbo.go ├── dubbo_test.go ├── filter ├── README.md ├── access_key.go ├── accesslog │ ├── filter.go │ └── filter_test.go ├── active │ ├── filter.go │ └── filter_test.go ├── adaptivesvc │ ├── filter.go │ ├── limiter │ │ ├── hill_climbing.go │ │ ├── limiter.go │ │ └── utils.go │ └── limiter_mapper.go ├── auth │ ├── accesskey_storage.go │ ├── accesskey_storage_test.go │ ├── consumer_sign_filter.go │ ├── consumer_sign_filter_test.go │ ├── default_authenticator.go │ ├── default_authenticator_test.go │ ├── doc.go │ ├── provider_auth_filter.go │ ├── provider_auth_filter_test.go │ ├── sign_util.go │ └── sign_util_test.go ├── authenticator.go ├── context │ └── filter.go ├── echo │ ├── filter.go │ └── filter_test.go ├── exec_limit │ ├── filter.go │ └── filter_test.go ├── filter.go ├── filter_impl │ └── import.go ├── generic │ ├── filter.go │ ├── filter_test.go │ ├── generalizer │ │ ├── example.pb.go │ │ ├── generalizer.go │ │ ├── gson.go │ │ ├── gson_test.go │ │ ├── map.go │ │ ├── map_test.go │ │ ├── protobuf_json.go │ │ └── protobuf_json_test.go │ ├── service_filter.go │ ├── service_filter_test.go │ └── util.go ├── graceful_shutdown │ ├── consumer_filter.go │ ├── consumer_filter_test.go │ ├── doc.go │ ├── provider_filter.go │ └── provider_filter_test.go ├── handler │ ├── rejected_execution_handler_mock.go │ ├── rejected_execution_handler_only_log.go │ └── rejected_execution_handler_only_log_test.go ├── hystrix │ ├── filter.go │ └── filter_test.go ├── metrics │ ├── filter.go │ └── filter_test.go ├── otel │ └── trace │ │ ├── attachment.go │ │ ├── attachment_test.go │ │ ├── doc.go │ │ ├── filter.go │ │ ├── filter_test.go │ │ └── semconv.go ├── polaris │ └── limit │ │ ├── default.go │ │ └── limiter.go ├── rejected_execution_handler.go ├── seata │ ├── filter.go │ └── filter_test.go ├── sentinel │ ├── filter.go │ └── filter_test.go ├── token │ ├── filter.go │ └── filter_test.go ├── tps │ ├── filter.go │ ├── filter_test.go │ ├── limiter │ │ ├── method_service.go │ │ ├── method_service_test.go │ │ └── mock.go │ └── strategy │ │ ├── fix_window.go │ │ ├── fix_window_test.go │ │ ├── mock.go │ │ ├── sliding_window.go │ │ ├── sliding_window_test.go │ │ ├── thread_safe_fix_window.go │ │ └── thread_safe_fix_window_test.go ├── tps_limiter.go ├── tps_strategy.go └── tracing │ ├── filter.go │ └── filter_test.go ├── global ├── application_config.go ├── config_center_config.go ├── config_test.go ├── consumer_config.go ├── custom_config.go ├── doc.go ├── logger_config.go ├── metadata_report_config.go ├── method_config.go ├── metric_config.go ├── otel_config.go ├── profiles_config.go ├── protocol_config.go ├── provider_config.go ├── reference_config.go ├── registry_config.go ├── service_config.go ├── shutdown_config.go ├── tls_config.go └── tracing_config.go ├── go.mod ├── go.sum ├── graceful_shutdown ├── common.go ├── compat.go ├── graceful_shutdown_signal_darwin.go ├── graceful_shutdown_signal_linux.go ├── graceful_shutdown_signal_windows.go ├── options.go └── shutdown.go ├── imports └── imports.go ├── integrate_test.sh ├── internal ├── internal.go └── reflection │ └── api.go ├── loader.go ├── logger ├── logger.go ├── logrus │ └── logrus.go ├── options.go └── zap │ └── zap.go ├── metadata ├── client.go ├── client_test.go ├── info │ ├── metadata_info.go │ └── metadata_info_test.go ├── mapping │ ├── metadata │ │ ├── service_name_mapping.go │ │ └── service_name_mapping_test.go │ └── service_name_mapping.go ├── metadata.go ├── metadata_service.go ├── metadata_service_test.go ├── metadata_test.go ├── options.go ├── report │ ├── etcd │ │ ├── report.go │ │ └── report_test.go │ ├── nacos │ │ ├── report.go │ │ └── report_test.go │ ├── report.go │ ├── report_factory.go │ └── zookeeper │ │ ├── listener.go │ │ └── report.go ├── report_instance.go ├── report_instance_test.go └── triple_api │ └── proto │ ├── hessian2_extend │ └── hessian2_extend.proto │ ├── java8_time │ └── java8_time.proto │ ├── java_exception │ └── java_exception.proto │ ├── java_math │ └── java_math.proto │ ├── java_sql_time │ └── java_sql_time.proto │ ├── java_util │ └── java_util.proto │ ├── metadata_service.hessian2.go │ ├── metadata_service.proto │ ├── metadata_service_v2.pb.go │ ├── metadata_service_v2.proto │ └── self_extension │ └── self_extension.proto ├── metrics ├── api.go ├── app_info │ └── collector.go ├── bus.go ├── bus_test.go ├── common.go ├── config_center │ └── collector.go ├── doc.go ├── event.go ├── metadata │ ├── collector.go │ └── metric_set.go ├── options.go ├── prometheus │ ├── registry.go │ ├── registry_test.go │ ├── rt_vec.go │ └── rt_vec_test.go ├── registry │ ├── collector.go │ ├── event.go │ └── metric_set.go ├── reporter.go ├── rpc │ ├── collector.go │ ├── event.go │ ├── metric_set.go │ └── util.go └── util │ └── aggregate │ ├── aggregator.go │ ├── aggregator_test.go │ ├── counter.go │ ├── counter_test.go │ ├── pane.go │ ├── quantile.go │ ├── quantile_test.go │ └── sliding_window.go ├── options.go ├── otel └── trace │ ├── doc.go │ ├── exporter.go │ ├── jaeger │ └── exporter.go │ ├── options.go │ ├── otlp │ └── exporter.go │ ├── stdout │ └── exporter.go │ └── zipkin │ └── exporter.go ├── protocol ├── dubbo │ ├── doc.go │ ├── dubbo_codec.go │ ├── dubbo_exporter.go │ ├── dubbo_invoker.go │ ├── dubbo_invoker_test.go │ ├── dubbo_protocol.go │ ├── dubbo_protocol_test.go │ ├── example │ │ └── new │ │ │ ├── client │ │ │ └── main.go │ │ │ └── server │ │ │ └── main.go │ ├── hessian2 │ │ ├── const.go │ │ ├── hessian_dubbo.go │ │ ├── hessian_dubbo_test.go │ │ ├── hessian_request.go │ │ ├── hessian_request_test.go │ │ ├── hessian_response.go │ │ ├── hessian_response_test.go │ │ ├── java_class.go │ │ └── java_class_test.go │ ├── impl │ │ ├── codec.go │ │ ├── codec_test.go │ │ ├── const.go │ │ ├── hessian.go │ │ ├── hessian_test.go │ │ ├── package.go │ │ ├── request.go │ │ ├── response.go │ │ ├── serialization.go │ │ └── serialize.go │ └── opentracing.go ├── dubbo3 │ ├── common_test.go │ ├── doc.go │ ├── dubbo3_exporter.go │ ├── dubbo3_invoker.go │ ├── dubbo3_invoker_test.go │ ├── dubbo3_protocol.go │ ├── dubbo3_protocol_test.go │ └── internal │ │ ├── client.go │ │ ├── helloworld.pb.go │ │ ├── helloworld.proto │ │ ├── helloworld_triple.pb.go │ │ └── server.go ├── grpc │ ├── client.go │ ├── client_test.go │ ├── codec.go │ ├── config.go │ ├── doc.go │ ├── grpc_exporter.go │ ├── grpc_invoker.go │ ├── grpc_invoker_test.go │ ├── grpc_protocol.go │ ├── grpc_protocol_test.go │ ├── internal │ │ ├── README.md │ │ ├── doc.go │ │ ├── helloworld │ │ │ ├── Makefile │ │ │ ├── client.go │ │ │ ├── helloworld.pb.go │ │ │ ├── helloworld.proto │ │ │ └── server.go │ │ ├── multiprotos │ │ │ ├── Makefile │ │ │ ├── first.pb.go │ │ │ ├── first.proto │ │ │ ├── second.pb.go │ │ │ └── second.proto │ │ └── routeguide │ │ │ ├── Makefile │ │ │ ├── client.go │ │ │ ├── routeguide.pb.go │ │ │ ├── routeguide.proto │ │ │ └── server.go │ ├── protoc-gen-dubbo │ │ └── plugin │ │ │ └── dubbo │ │ │ └── dubbo.go │ └── server.go ├── invocation.go ├── invocation │ ├── rpcinvocation.go │ └── rpcinvocation_test.go ├── invoker.go ├── invoker_test.go ├── jsonrpc │ ├── doc.go │ ├── http.go │ ├── http_test.go │ ├── json.go │ ├── json_test.go │ ├── jsonrpc_exporter.go │ ├── jsonrpc_invoker.go │ ├── jsonrpc_invoker_test.go │ ├── jsonrpc_protocol.go │ ├── jsonrpc_protocol_test.go │ └── server.go ├── mock │ └── mock_invoker.go ├── options.go ├── protocol.go ├── protocolwrapper │ ├── mock_protocol_filter.go │ ├── protocol_filter_wrapper.go │ └── protocol_filter_wrapper_test.go ├── rest │ ├── client │ │ ├── client_impl │ │ │ └── resty_client.go │ │ └── rest_client.go │ ├── config │ │ ├── reader │ │ │ ├── rest_config_reader.go │ │ │ ├── rest_config_reader_test.go │ │ │ └── testdata │ │ │ │ ├── consumer_config.yml │ │ │ │ └── provider_config.yml │ │ └── rest_config.go │ ├── doc.go │ ├── rest_exporter.go │ ├── rest_invoker.go │ ├── rest_invoker_test.go │ ├── rest_protocol.go │ ├── rest_protocol_test.go │ └── server │ │ ├── rest_server.go │ │ └── server_impl │ │ ├── go_restful_server.go │ │ └── go_restful_server_test.go ├── result.go ├── rpc_status.go ├── rpc_status_test.go └── triple │ ├── client.go │ ├── common.go │ ├── common_low_version.go │ ├── dubbo3_invoker.go │ ├── health │ ├── healthServer.go │ ├── health_test.go │ └── triple_health │ │ ├── health.pb.go │ │ ├── health.proto │ │ └── health.triple.go │ ├── reflection │ ├── serverreflection.go │ └── triple_reflection │ │ ├── reflection.pb.go │ │ ├── reflection.proto │ │ └── reflection.triple.go │ ├── server.go │ ├── server_test.go │ ├── triple.go │ ├── triple_exporter.go │ ├── triple_invoker.go │ ├── triple_invoker_test.go │ └── triple_protocol │ ├── Makefile │ ├── bench_test.go │ ├── buffer_pool.go │ ├── client.go │ ├── client_example_test.go │ ├── client_ext_test.go │ ├── client_stream.go │ ├── client_stream_test.go │ ├── code.go │ ├── code_test.go │ ├── codec.go │ ├── codec_test.go │ ├── compression.go │ ├── compression_test.go │ ├── duplex_http_call.go │ ├── envelope.go │ ├── error.go │ ├── error_example_test.go │ ├── error_test.go │ ├── error_writer.go │ ├── error_writer_example_test.go │ ├── example_init_test.go │ ├── handler.go │ ├── handler_compat.go │ ├── handler_compat_test.go │ ├── handler_example_test.go │ ├── handler_ext_test.go │ ├── handler_stream.go │ ├── handler_stream_compat.go │ ├── header.go │ ├── header_compat.go │ ├── header_test.go │ ├── idempotency_level.go │ ├── interceptor.go │ ├── interceptor_example_test.go │ ├── interceptor_ext_test.go │ ├── internal │ ├── assert │ │ ├── assert.go │ │ └── assert_test.go │ ├── gen │ │ └── proto │ │ │ ├── connect │ │ │ ├── collide │ │ │ │ └── v1 │ │ │ │ │ └── collide.pb.go │ │ │ ├── import │ │ │ │ └── v1 │ │ │ │ │ ├── import.pb.go │ │ │ │ │ └── importv1connect │ │ │ │ │ └── import.connect.go │ │ │ └── ping │ │ │ │ └── v1 │ │ │ │ ├── ping.pb.go │ │ │ │ └── pingv1connect │ │ │ │ └── ping.connect.go │ │ │ └── connectext │ │ │ └── grpc │ │ │ └── status │ │ │ └── v1 │ │ │ └── status.pb.go │ ├── interoperability │ │ ├── interop.triple_wrapper.pb.go │ │ └── interop.triple_wrapper.proto │ ├── proto │ │ ├── buf.gen.yaml │ │ ├── buf.yaml │ │ ├── connectext │ │ │ └── grpc │ │ │ │ └── status │ │ │ │ └── v1 │ │ │ │ ├── status.pb.go │ │ │ │ └── status.proto │ │ └── triple │ │ │ ├── collide │ │ │ └── v1 │ │ │ │ └── collide.proto │ │ │ ├── import │ │ │ └── v1 │ │ │ │ └── import.proto │ │ │ └── ping │ │ │ └── v1 │ │ │ └── ping.proto │ └── testdata │ │ ├── server.crt │ │ └── server.key │ ├── maxbytes.go │ ├── maxbytes_low_version.go │ ├── option.go │ ├── protobuf_util.go │ ├── protobuf_util_test.go │ ├── protocol.go │ ├── protocol_grpc.go │ ├── protocol_grpc_test.go │ ├── protocol_test.go │ ├── protocol_triple.go │ ├── protocol_triple_test.go │ ├── recover.go │ ├── recover_ext_test.go │ ├── server.go │ ├── server_test.go │ ├── triple.go │ └── triple_ext_test.go ├── proxy ├── proxy.go ├── proxy_factory.go ├── proxy_factory │ ├── default.go │ ├── default_test.go │ ├── pass_through.go │ ├── pass_through_test.go │ └── utils.go └── proxy_test.go ├── registry ├── base_configuration_listener.go ├── base_registry.go ├── directory │ ├── directory.go │ ├── directory_test.go │ └── doc.go ├── doc.go ├── etcdv3 │ ├── doc.go │ ├── listener.go │ ├── listener_test.go │ ├── registry.go │ ├── registry_test.go │ ├── service_discovery.go │ └── service_discovery_test.go ├── event.go ├── event_test.go ├── exposed_tmp │ └── exposed.go ├── mock_registry.go ├── mocks │ └── NotifyListener.go ├── nacos │ ├── doc.go │ ├── listener.go │ ├── registry.go │ ├── registry_test.go │ ├── service_discovery.go │ └── service_discovery_test.go ├── options.go ├── polaris │ ├── core.go │ ├── doc.go │ ├── listener.go │ ├── registry.go │ ├── service_discovery.go │ └── utils.go ├── protocol │ ├── protocol.go │ └── protocol_test.go ├── registry.go ├── registry_factory.go ├── service_discovery.go ├── service_instance.go ├── service_instances_changed_listener.go ├── servicediscovery │ ├── customizer │ │ ├── metadata_service_url_params_customizer.go │ │ ├── metadata_service_url_params_customizer_test.go │ │ ├── metadata_service_version_customizer.go │ │ ├── protocol_ports_metadata_customizer.go │ │ ├── service_instance_host_port_customizer.go │ │ └── service_revision_customizer.go │ ├── instance │ │ ├── random │ │ │ ├── random_service_instance_selector.go │ │ │ └── random_service_instance_selector_test.go │ │ └── service_instance_selector.go │ ├── service_discovery_registry.go │ ├── service_discovery_registry_test.go │ ├── service_instances_changed_listener_impl.go │ ├── service_mapping_change_listener_impl.go │ ├── store │ │ ├── cache_manager.go │ │ └── cache_manager_test.go │ └── synthesizer │ │ ├── rest │ │ ├── rest_subscribed_urls_synthesizer.go │ │ └── rest_subscribed_urls_synthesizer_test.go │ │ ├── subscribed_urls_synthesizer.go │ │ └── subscribed_urls_synthesizer_factory.go └── zookeeper │ ├── doc.go │ ├── listener.go │ ├── registry.go │ ├── service_discovery.go │ └── service_discovery_test.go ├── remoting ├── codec.go ├── doc.go ├── etcdv3 │ ├── client.go │ ├── facade.go │ ├── listener.go │ └── listener_test.go ├── exchange.go ├── exchange_client.go ├── exchange_server.go ├── getty │ ├── config.go │ ├── dubbo_codec_for_test.go │ ├── getty_client.go │ ├── getty_client_test.go │ ├── getty_server.go │ ├── getty_server_test.go │ ├── listener.go │ ├── listener_test.go │ ├── opentracing.go │ ├── pool.go │ ├── readwriter.go │ └── readwriter_test.go ├── listener.go ├── nacos │ ├── builder.go │ └── builder_test.go ├── polaris │ ├── builder.go │ ├── builder_test.go │ ├── parser │ │ ├── parser.go │ │ └── parser_test.go │ └── polaris.yaml └── zookeeper │ ├── client.go │ ├── curator_discovery │ ├── service_discovery.go │ └── service_instance.go │ ├── facade.go │ ├── listener.go │ └── listener_test.go ├── server ├── action.go ├── compat.go ├── options.go └── server.go └── tools ├── dubbo-go-schema ├── README.md ├── application.yaml ├── dubbo-go.json └── images │ ├── img.png │ ├── img_1.png │ └── vs-code.png └── dubbogo-cli ├── Makefile ├── README.md ├── README_CN.md ├── cmd ├── call.go ├── gen.go ├── gen_test.go ├── hessian.go ├── install.go ├── new_demo.go ├── root.go ├── show.go ├── testGenCode │ └── template │ │ ├── newApp │ │ ├── .gitignore │ │ ├── Makefile │ │ ├── api │ │ │ ├── api.pb.go │ │ │ ├── api.proto │ │ │ └── api_triple.pb.go │ │ ├── build │ │ │ └── Dockerfile │ │ ├── chart │ │ │ ├── app │ │ │ │ ├── Chart.yaml │ │ │ │ ├── templates │ │ │ │ │ ├── _helpers.tpl │ │ │ │ │ ├── deployment.yaml │ │ │ │ │ ├── service.yaml │ │ │ │ │ └── serviceaccount.yaml │ │ │ │ └── values.yaml │ │ │ └── nacos_env │ │ │ │ ├── Chart.yaml │ │ │ │ ├── templates │ │ │ │ ├── _helpers.tpl │ │ │ │ ├── deployment.yaml │ │ │ │ └── service.yaml │ │ │ │ └── values.yaml │ │ ├── cmd │ │ │ └── app.go │ │ ├── conf │ │ │ └── dubbogo.yaml │ │ ├── go.mod │ │ ├── go.sum │ │ └── pkg │ │ │ └── service │ │ │ └── service.go │ │ └── newDemo │ │ ├── api │ │ ├── samples_api.pb.go │ │ ├── samples_api.proto │ │ └── samples_api_triple.pb.go │ │ ├── go-client │ │ ├── cmd │ │ │ └── client.go │ │ └── conf │ │ │ └── dubbogo.yaml │ │ ├── go-server │ │ ├── cmd │ │ │ └── server.go │ │ └── conf │ │ │ └── dubbogo.yaml │ │ ├── go.mod │ │ └── go.sum └── version.go ├── constant └── constant.go ├── generator ├── application │ ├── api.go │ ├── build.go │ ├── chart.go │ ├── cmd.go │ ├── conf.go │ ├── generator.go │ ├── gitignore.go │ ├── gomod.go │ ├── makefile.go │ └── pkg.go └── sample │ ├── api.go │ ├── api_tripe.go │ ├── constants.go │ ├── gen_c_conf.go │ ├── gen_client.go │ ├── gen_s_conf.go │ ├── gen_server.go │ ├── generator.go │ ├── hessian │ ├── constant.go │ ├── file_scanner.go │ ├── generator.go │ ├── logger.go │ └── pool.go │ ├── hessian_generator.go │ ├── mod.go │ └── proto.go ├── go.mod ├── go.sum ├── internal ├── client │ └── client.go ├── common │ ├── protocol.go │ └── tool.go ├── json_register │ └── json_register.go └── protocol │ ├── dubbo │ ├── codec.go │ └── dubbo_protocol.go │ ├── dubbo3 │ ├── codec.go │ └── dubbo_protocol.go │ └── protocol.go ├── main.go └── metadata ├── metadata.go └── zookeeper └── zookeeper.go /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Report a bug 4 | labels: kind/bug 5 | 6 | --- 7 | 8 | ### Environment 9 | 10 | 16 | 17 | - Server: 18 | - Client: 19 | - Protocol: 20 | - Registry: 21 | 22 | ### Issue description 23 | 24 | 25 | 26 | ### Logs 27 | 28 |
Click me to check logs 29 | 30 | ``` 31 | Copy logs to here. 32 | ``` 33 | 34 |
35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/enhancement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Enhancement Request 3 | about: Suggest an enhancement 4 | labels: kind/feature 5 | 6 | --- 7 | 8 | 9 | **What would you like to be added**: 10 | 11 | **Why is this needed**: -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "gomod" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | target-branch: "3.0" 13 | 14 | - package-ecosystem: "github-actions" 15 | # Workflow files stored in the 16 | # default location of `.github/workflows` 17 | directory: "/" 18 | schedule: 19 | interval: "monthly" 20 | target-branch: "3.0" 21 | -------------------------------------------------------------------------------- /.github/workflows/golangci-lint.yml: -------------------------------------------------------------------------------- 1 | name: golangci-lint 2 | on: 3 | push: 4 | branches: "*" 5 | pull_request: 6 | branches: "*" 7 | 8 | permissions: 9 | contents: read 10 | 11 | jobs: 12 | golangci: 13 | permissions: 14 | contents: read # for actions/checkout to fetch code 15 | pull-requests: read # for golangci/golangci-lint-action to fetch pull requests 16 | name: lint 17 | runs-on: ubuntu-latest 18 | strategy: 19 | matrix: 20 | golang: 21 | - "1.23" 22 | steps: 23 | - uses: actions/setup-go@v5 24 | with: 25 | go-version: ${{ matrix.golang }} 26 | - uses: actions/checkout@v4 27 | - name: golangci-lint 28 | uses: golangci/golangci-lint-action@v8 29 | with: 30 | version: v2.1.6 31 | args: --timeout=10m 32 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - develop 8 | 9 | pull_request: 10 | types: [opened, reopened, synchronize] 11 | 12 | 13 | permissions: 14 | contents: read 15 | 16 | jobs: 17 | update_release_draft: 18 | permissions: 19 | contents: write 20 | pull-requests: write 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: release-drafter/release-drafter@v6 24 | env: 25 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | *.jar 8 | *.log 9 | 10 | # Test binary, build with `go test -c` 11 | *.test 12 | 13 | # Output of the go coverage tool, specifically when used with LiteIDE 14 | *.out 15 | coverage.txt 16 | 17 | *.idea 18 | *.iml 19 | target/ 20 | classes 21 | 22 | # go mod, go test 23 | .go-version 24 | vendor/ 25 | logs/ 26 | .vscode/ 27 | cache 28 | log/ 29 | 30 | # unit test 31 | remoting/zookeeper/zookeeper-4unittest/ 32 | config_center/zookeeper/zookeeper-4unittest/ 33 | registry/zookeeper/zookeeper-4unittest/ 34 | metadata/report/zookeeper/zookeeper-4unittest/ 35 | 36 | # vim stuff 37 | *~ 38 | .*.sw? 39 | /license-header-checker-linux/ 40 | /license-header-checker-linux.zip 41 | 42 | # macOS 43 | .DS_Store 44 | .history 45 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "samples"] 2 | path = samples 3 | url = git@github.com:apache/dubbo-go-samples.git 4 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Apache Dubbo-go 2 | Copyright 2018-2025 The Apache Software Foundation 3 | 4 | This product includes software developed at 5 | The Apache Software Foundation (http://www.apache.org/). 6 | -------------------------------------------------------------------------------- /cluster/cluster/adaptivesvc/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package adaptivesvc implements adaptive service cluster strategy. 19 | package adaptivesvc 20 | -------------------------------------------------------------------------------- /cluster/cluster/available/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package available implements Available cluster strategy. 19 | package available 20 | -------------------------------------------------------------------------------- /cluster/cluster/broadcast/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package broadcast implements Broadcast cluster strategy. 19 | package broadcast 20 | -------------------------------------------------------------------------------- /cluster/cluster/cluster.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package cluster provides various LoadBalance and Cluster policies for client-side traffic management. 19 | package cluster 20 | 21 | import ( 22 | "dubbo.apache.org/dubbo-go/v3/cluster/directory" 23 | "dubbo.apache.org/dubbo-go/v3/protocol" 24 | ) 25 | 26 | type Cluster interface { 27 | Join(directory.Directory) protocol.Invoker 28 | } 29 | -------------------------------------------------------------------------------- /cluster/cluster/cluster_interceptor.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package cluster 19 | 20 | import ( 21 | "context" 22 | ) 23 | 24 | import ( 25 | "dubbo.apache.org/dubbo-go/v3/protocol" 26 | ) 27 | 28 | type Interceptor interface { 29 | // Invoke is the core function of a cluster interceptor, it determines the process of the interceptor 30 | Invoke(context.Context, protocol.Invoker, protocol.Invocation) protocol.Result 31 | } 32 | -------------------------------------------------------------------------------- /cluster/cluster/failback/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package failback implements Failback cluster strategy. 19 | package failback 20 | -------------------------------------------------------------------------------- /cluster/cluster/failfast/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package failfast implements Failfast cluster strategy. 19 | package failfast 20 | -------------------------------------------------------------------------------- /cluster/cluster/failover/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package failover implements Failover cluster strategy. 19 | package failover 20 | -------------------------------------------------------------------------------- /cluster/cluster/failsafe/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package failsafe implements Failsafe cluster strategy. 19 | package failsafe 20 | -------------------------------------------------------------------------------- /cluster/cluster/forking/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package forking implements forking cluster strategy. 19 | package forking 20 | -------------------------------------------------------------------------------- /cluster/cluster/zoneaware/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package zoneaware implements zoneaware cluster strategy. 19 | package zoneaware 20 | -------------------------------------------------------------------------------- /cluster/loadbalance/aliasmethod/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package aliasmethod implements alias-method algorithm load balance strategy. 19 | // Alias Method: https://en.wikipedia.org/wiki/Alias_method 20 | // It needs O(n) time and O(n) memory to initialize and O(1) time to generate a random number. 21 | package aliasmethod // weighted random with alias-method algorithm 22 | -------------------------------------------------------------------------------- /cluster/loadbalance/consistenthashing/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package consistenthashing implements ConsistentHash load balance strategy. 19 | package consistenthashing 20 | -------------------------------------------------------------------------------- /cluster/loadbalance/iwrr/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package iwrr implements Interleaved Weighted Round Robin load balance strategy. 19 | // Interleaved Weighted Round Robin: https://en.wikipedia.org/wiki/Weighted_round_robin#Interleaved_WRR 20 | // It needs O(n log maxWeight) time and O(n) memory to initialize and O(1) time to generate a random number. 21 | package iwrr 22 | -------------------------------------------------------------------------------- /cluster/loadbalance/leastactive/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package leastactive implements LeastActive load balance strategy. 19 | package leastactive 20 | -------------------------------------------------------------------------------- /cluster/loadbalance/loadbalance.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package loadbalance 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/protocol" 22 | ) 23 | 24 | type LoadBalance interface { 25 | Select([]protocol.Invoker, protocol.Invocation) protocol.Invoker 26 | } 27 | -------------------------------------------------------------------------------- /cluster/loadbalance/p2c/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package p2c implements p2c load balance strategy. 19 | package p2c 20 | -------------------------------------------------------------------------------- /cluster/loadbalance/random/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package random implements Random load balance strategy. 19 | package random 20 | -------------------------------------------------------------------------------- /cluster/loadbalance/roundrobin/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package roundrobin implements RoundRobin load balance strategy. 19 | package roundrobin 20 | -------------------------------------------------------------------------------- /cluster/metrics/constants.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package metrics 19 | 20 | const ( 21 | HillClimbing = "hill-climbing" 22 | ) 23 | -------------------------------------------------------------------------------- /cluster/metrics/utils.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package metrics 19 | 20 | import ( 21 | "fmt" 22 | ) 23 | 24 | import ( 25 | "dubbo.apache.org/dubbo-go/v3/common" 26 | ) 27 | 28 | func getInvokerKey(url *common.URL) string { 29 | return url.Path 30 | } 31 | 32 | func getInstanceKey(url *common.URL) string { 33 | return fmt.Sprintf("%s:%s", url.Ip, url.Port) 34 | } 35 | -------------------------------------------------------------------------------- /cluster/router/chain.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package router 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common" 22 | "dubbo.apache.org/dubbo-go/v3/protocol" 23 | ) 24 | 25 | type Chain interface { 26 | Route(*common.URL, protocol.Invocation) []protocol.Invoker 27 | // Refresh invokers 28 | SetInvokers([]protocol.Invoker) 29 | // AddRouters Add routers 30 | AddRouters([]PriorityRouter) 31 | } 32 | -------------------------------------------------------------------------------- /cluster/router/condition/matcher/param.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package matcher 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common" 22 | "dubbo.apache.org/dubbo-go/v3/protocol" 23 | ) 24 | 25 | type ParamConditionMatcher struct { 26 | BaseConditionMatcher 27 | } 28 | 29 | func NewParamConditionMatcher(key string) *ParamConditionMatcher { 30 | return &ParamConditionMatcher{ 31 | *NewBaseConditionMatcher(key), 32 | } 33 | } 34 | 35 | func (p *ParamConditionMatcher) GetValue(sample map[string]string, url *common.URL, invocation protocol.Invocation) string { 36 | return GetSampleValueFromURL(p.key, sample, url, invocation) 37 | } 38 | -------------------------------------------------------------------------------- /cluster/router/polaris/default.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package polaris 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common/constant" 22 | "dubbo.apache.org/dubbo-go/v3/common/extension" 23 | ) 24 | 25 | func init() { 26 | extension.SetRouterFactory(constant.PluginPolarisRouterFactory, NewPolarisRouterFactory) 27 | } 28 | -------------------------------------------------------------------------------- /cluster/router/polaris/factory.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package polaris 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/cluster/router" 22 | ) 23 | 24 | // RouteFactory router factory 25 | type RouteFactory struct{} 26 | 27 | // NewPolarisRouterFactory constructs a new PriorityRouterFactory 28 | func NewPolarisRouterFactory() router.PriorityRouterFactory { 29 | return &RouteFactory{} 30 | } 31 | 32 | // NewPriorityRouter construct a new PriorityRouter 33 | func (f *RouteFactory) NewPriorityRouter() (router.PriorityRouter, error) { 34 | return newPolarisRouter() 35 | } 36 | -------------------------------------------------------------------------------- /common/constant/file/suffix.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package file 19 | 20 | type Suffix string 21 | 22 | const ( 23 | JSON = Suffix("json") 24 | TOML = Suffix("toml") 25 | YAML = Suffix("yaml") 26 | YML = Suffix("yml") 27 | PROPERTIES = Suffix("properties") 28 | ) 29 | 30 | const ( 31 | PlaceholderPrefix = "${" 32 | PlaceholderSuffix = "}" 33 | ) 34 | -------------------------------------------------------------------------------- /common/constant/loadbalance.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package constant 19 | 20 | const ( 21 | LoadBalanceKeyConsistentHashing = "consistenthashing" 22 | LoadBalanceKeyLeastActive = "leastactive" 23 | LoadBalanceKeyRandom = "random" 24 | LoadBalanceKeyRoundRobin = "roundrobin" 25 | LoadBalanceKeyP2C = "p2c" 26 | LoadXDSRingHash = "xdsringhash" 27 | LoadBalanceKeyInterleavedWeightedRoundRobin = "interleavedweightedroundrobin" 28 | LoadBalanceKeyAliasMethod = "aliasmethod" 29 | ) 30 | -------------------------------------------------------------------------------- /common/constant/otel.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package constant 19 | 20 | const ( 21 | OtelPackageName = "go.opentelemetry.io/otel" 22 | OtelPackageVersion = "v1.10.0" 23 | ) 24 | -------------------------------------------------------------------------------- /common/constant/serialization.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package constant 19 | 20 | const ( 21 | SHessian2 byte = 2 22 | SProto byte = 21 23 | ) 24 | 25 | const ( 26 | Hessian2Serialization = "hessian2" 27 | ProtobufSerialization = "protobuf" 28 | MsgpackSerialization = "msgpack" 29 | JSONSerialization = "json" 30 | ) 31 | -------------------------------------------------------------------------------- /common/constant/time.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package constant 19 | 20 | import ( 21 | "time" 22 | ) 23 | 24 | // MsToNanoRate will be 10^6, 1ms = 10^6ns 25 | var MsToNanoRate = int64(time.Millisecond / time.Nanosecond) 26 | -------------------------------------------------------------------------------- /common/constant/version.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package constant 19 | 20 | const ( 21 | Version = "3.2.0" // apache/dubbo-go version 22 | Name = "dubbogo" // module name 23 | DATE = "2024/1/10" // release date 24 | RouteVersion = "v3.1" 25 | ) 26 | -------------------------------------------------------------------------------- /common/constant/xds.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package constant 19 | 20 | const ( 21 | EndPointWeight = "endPointWeight" 22 | ) 23 | 24 | const ( 25 | MeshClusterIDKey = "meshClusterID" 26 | MeshHostAddrKey = "meshHostAddr" 27 | MeshSubsetKey = "meshSubset" 28 | 29 | MeshDeleteClusterPrefix = "-" 30 | MeshAnyAddrMatcher = "*" 31 | ) 32 | 33 | const ( 34 | XDSMetadataClusterIDKey = "CLUSTER_ID" 35 | XDSMetadataLabelsKey = "LABELS" 36 | 37 | XDSMetadataDefaultDomainName = "Kubernetes" 38 | 39 | XDSMetadataDubboGoMapperKey = "DUBBO_GO" 40 | ) 41 | -------------------------------------------------------------------------------- /common/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package common contains the utilities and SPI plugin mechanism used across Dubbo project. 19 | package common 20 | -------------------------------------------------------------------------------- /common/dubboutil/case_invert.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package server provides APIs for registering services and starting an RPC server. 19 | 20 | package dubboutil 21 | 22 | import ( 23 | "unicode" 24 | ) 25 | 26 | func SwapCaseFirstRune(s string) string { 27 | if s == "" { 28 | return s 29 | } 30 | 31 | // convert str to rune slice 32 | r := []rune(s) 33 | if unicode.IsUpper(r[0]) { 34 | r[0] = unicode.ToLower(r[0]) 35 | } else { 36 | r[0] = unicode.ToUpper(r[0]) 37 | } 38 | return string(r) 39 | } 40 | -------------------------------------------------------------------------------- /common/extension/config.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package extension 19 | 20 | var ( 21 | configs = map[string]Config{} 22 | ) 23 | 24 | type Config interface { 25 | Prefix() string 26 | } 27 | 28 | func SetConfig(c Config) { 29 | configs[c.Prefix()] = c 30 | } 31 | -------------------------------------------------------------------------------- /common/extension/protocol.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package extension 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/protocol" 22 | ) 23 | 24 | var protocols = make(map[string]func() protocol.Protocol) 25 | 26 | // SetProtocol sets the protocol extension with @name 27 | func SetProtocol(name string, v func() protocol.Protocol) { 28 | protocols[name] = v 29 | } 30 | 31 | // GetProtocol finds the protocol extension with @name 32 | func GetProtocol(name string) protocol.Protocol { 33 | if protocols[name] == nil { 34 | panic("protocol for " + name + " is not existing, make sure you have import the package.") 35 | } 36 | return protocols[name]() 37 | } 38 | -------------------------------------------------------------------------------- /common/extension/rest_server.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package extension 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/protocol/rest/server" 22 | ) 23 | 24 | var restServers = make(map[string]func() server.RestServer, 8) 25 | 26 | // SetRestServer sets the RestServer with @name 27 | func SetRestServer(name string, fun func() server.RestServer) { 28 | restServers[name] = fun 29 | } 30 | 31 | // GetNewRestServer finds the RestServer with @name 32 | func GetNewRestServer(name string) server.RestServer { 33 | if restServers[name] == nil { 34 | panic("restServer for " + name + " is not existing, make sure you have import the package.") 35 | } 36 | return restServers[name]() 37 | } 38 | -------------------------------------------------------------------------------- /common/extension/service_name_mapping.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package extension 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/metadata/mapping" 22 | ) 23 | 24 | type ServiceNameMappingCreator func() mapping.ServiceNameMapping 25 | 26 | var globalNameMappingCreator ServiceNameMappingCreator 27 | 28 | func SetGlobalServiceNameMapping(nameMappingCreator ServiceNameMappingCreator) { 29 | globalNameMappingCreator = nameMappingCreator 30 | } 31 | 32 | func GetGlobalServiceNameMapping() mapping.ServiceNameMapping { 33 | return globalNameMappingCreator() 34 | } 35 | -------------------------------------------------------------------------------- /common/node.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package common 19 | 20 | // Node use for process dubbo node 21 | type Node interface { 22 | GetURL() *URL 23 | IsAvailable() bool 24 | Destroy() 25 | } 26 | -------------------------------------------------------------------------------- /config/config_setter.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | type Setter interface { 21 | Set(name string, config any) 22 | } 23 | -------------------------------------------------------------------------------- /config/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package config assembles all Dubbo configurations and works as the entrance of the whole Dubbo process. 19 | // 20 | // Deprecated: This package is for internal use only starting from 3.2.0, users must not depend on this package directly. 21 | package config 22 | -------------------------------------------------------------------------------- /config/generic/generic_service_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package generic 19 | 20 | import ( 21 | "testing" 22 | ) 23 | 24 | import ( 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | func TestGenericService(t *testing.T) { 29 | service := NewGenericService("HelloService") 30 | reference := service.Reference() 31 | assert.Equal(t, reference, "HelloService") 32 | } 33 | -------------------------------------------------------------------------------- /config/graceful_shutdown_signal_darwin.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "os" 22 | "syscall" 23 | ) 24 | 25 | var ( 26 | // ShutdownSignals receives shutdown signals to process 27 | ShutdownSignals = []os.Signal{ 28 | os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGSTOP, 29 | syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, 30 | syscall.SIGABRT, syscall.SIGSYS, syscall.SIGTERM, 31 | } 32 | 33 | // DumpHeapShutdownSignals receives shutdown signals to process 34 | DumpHeapShutdownSignals = []os.Signal{ 35 | syscall.SIGQUIT, syscall.SIGILL, 36 | syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS, 37 | } 38 | ) 39 | -------------------------------------------------------------------------------- /config/graceful_shutdown_signal_linux.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "os" 22 | "syscall" 23 | ) 24 | 25 | var ( 26 | // ShutdownSignals receives shutdown signals to process 27 | ShutdownSignals = []os.Signal{ 28 | os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGSTOP, 29 | syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, 30 | syscall.SIGABRT, syscall.SIGSYS, syscall.SIGTERM, 31 | } 32 | 33 | // DumpHeapShutdownSignals receives shutdown signals to process 34 | DumpHeapShutdownSignals = []os.Signal{ 35 | syscall.SIGQUIT, syscall.SIGILL, 36 | syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS, 37 | } 38 | ) 39 | -------------------------------------------------------------------------------- /config/graceful_shutdown_signal_windows.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "os" 22 | "syscall" 23 | ) 24 | 25 | var ( 26 | // ShutdownSignals receives shutdown signals to process 27 | ShutdownSignals = []os.Signal{ 28 | os.Interrupt, os.Kill, syscall.SIGKILL, 29 | syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, 30 | syscall.SIGABRT, syscall.SIGTERM, 31 | } 32 | 33 | // DumpHeapShutdownSignals receives shutdown signals to process 34 | DumpHeapShutdownSignals = []os.Signal{syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, syscall.SIGABRT} 35 | ) 36 | -------------------------------------------------------------------------------- /config/interfaces/config_post_processor.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package interfaces 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common" 22 | ) 23 | 24 | // ConfigPostProcessor is an extension to give users a chance to customize configs against ReferenceConfig and 25 | // ServiceConfig during deployment time. 26 | type ConfigPostProcessor interface { 27 | // PostProcessReferenceConfig customizes ReferenceConfig's params. 28 | PostProcessReferenceConfig(*common.URL) 29 | 30 | // PostProcessServiceConfig customizes ServiceConfig's params. 31 | PostProcessServiceConfig(*common.URL) 32 | } 33 | -------------------------------------------------------------------------------- /config/interfaces/config_reader.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package interfaces 19 | 20 | import ( 21 | "bytes" 22 | ) 23 | 24 | // ConfigReader is used to read config from consumer or provider 25 | type ConfigReader interface { 26 | ReadConsumerConfig(reader *bytes.Buffer) error 27 | ReadProviderConfig(reader *bytes.Buffer) error 28 | } 29 | -------------------------------------------------------------------------------- /config/metric_config_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "testing" 22 | ) 23 | 24 | import ( 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | func TestMetricConfigBuilder(t *testing.T) { 29 | config := NewMetricConfigBuilder(). 30 | SetConfigCenterEnabled(false). 31 | SetMetadataEnabled(false). 32 | SetRegistryEnabled(false). 33 | Build() 34 | enable := false 35 | assert.Equal(t, &MetricsConfig{ 36 | EnableConfigCenter: &enable, 37 | EnableMetadata: &enable, 38 | EnableRegistry: &enable, 39 | }, config) 40 | } 41 | -------------------------------------------------------------------------------- /config/mock_rpcservice.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "context" 22 | ) 23 | 24 | // MockService mocks the rpc service for test 25 | type MockService struct{} 26 | 27 | // Reference mocks the Reference method 28 | func (*MockService) Reference() string { 29 | return "MockService" 30 | } 31 | 32 | // GetUser mocks the GetUser method 33 | func (*MockService) GetUser(ctx context.Context, itf []any, str *struct{}) error { 34 | return nil 35 | } 36 | 37 | // GetUser1 mocks the GetUser1 method 38 | func (*MockService) GetUser1(ctx context.Context, itf []any, str *struct{}) error { 39 | return nil 40 | } 41 | -------------------------------------------------------------------------------- /config/mock_rpcservice_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "context" 22 | "testing" 23 | ) 24 | 25 | import ( 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestMockService(t *testing.T) { 30 | 31 | mockService := &MockService{} 32 | reference := mockService.Reference() 33 | assert.Equal(t, reference, "MockService") 34 | 35 | err := mockService.GetUser1(context.TODO(), nil, nil) 36 | assert.NoError(t, err) 37 | err = mockService.GetUser(context.TODO(), nil, nil) 38 | assert.NoError(t, err) 39 | } 40 | -------------------------------------------------------------------------------- /config/otel_config_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "testing" 22 | ) 23 | 24 | import ( 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | func TestNewOtelConfigBuilder(t *testing.T) { 29 | config := NewOtelConfigBuilder().Build() 30 | assert.NotNil(t, config) 31 | assert.NotNil(t, config.TraceConfig) 32 | 33 | ac := NewApplicationConfigBuilder().Build() 34 | err := config.Init(ac) 35 | assert.NoError(t, err) 36 | 37 | tpc := config.TraceConfig.toTraceProviderConfig(ac) 38 | assert.NotNil(t, tpc) 39 | } 40 | -------------------------------------------------------------------------------- /config/profiles_config.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common/constant" 22 | ) 23 | 24 | var ( 25 | defaultActive = "default" 26 | ) 27 | 28 | type ProfilesConfig struct { 29 | // active profiles 30 | Active string 31 | } 32 | 33 | // Prefix dubbo.profiles 34 | func (ProfilesConfig) Prefix() string { 35 | return constant.ProfilesConfigPrefix 36 | } 37 | 38 | // getLegalActive if active is null return default 39 | func getLegalActive(active string) string { 40 | if len(active) == 0 { 41 | return defaultActive 42 | } 43 | return active 44 | } 45 | -------------------------------------------------------------------------------- /config/service_discovery_config_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "testing" 22 | ) 23 | 24 | import ( 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | import ( 29 | "dubbo.apache.org/dubbo-go/v3/common/constant" 30 | ) 31 | 32 | func TestNewServiceDiscoveryConfigBuilder(t *testing.T) { 33 | 34 | config := NewServiceDiscoveryConfigBuilder(). 35 | SetProtocol("protocol"). 36 | SetGroup("group"). 37 | SetRemoteRef("remote"). 38 | Build() 39 | 40 | err := config.Init() 41 | assert.Nil(t, err) 42 | assert.Equal(t, config.Protocol, "protocol") 43 | assert.Equal(t, config.Prefix(), constant.ServiceDiscPrefix) 44 | } 45 | -------------------------------------------------------------------------------- /config/testdata/application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | application: 3 | name: dubbo-go 4 | module: local 5 | version: 1.0.0 6 | owner: zhaoyunxing 7 | config-center: 8 | address: nacos://127.0.0.1:8848 9 | cluster: dev 10 | namespace: dubbo 11 | log-dir: ./logs 12 | protocols: 13 | dubbo: 14 | name: dubbo 15 | ip: 127.0.0.1 16 | port: 20000 17 | registries: 18 | nacos: 19 | timeout: 5s 20 | group: dev 21 | address: nacos://127.0.0.1:8848 22 | zk: 23 | protocol: zookeeper 24 | group: dev 25 | address: 127.0.0.1:2181 26 | services: 27 | helloService: 28 | interface: org.dubbo.service.HelloService 29 | registry-ids: nacos,zk 30 | orderService: 31 | interface: org.dubbo.service.OrderService 32 | registry-ids: nacos 33 | provider: 34 | register: true 35 | services: -------------------------------------------------------------------------------- /config/testdata/config/active/application-local.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | profiles: 3 | active: local 4 | registries: 5 | nacos: 6 | timeout: 10s 7 | address: nacos://127.0.0.1:8848 8 | protocols: 9 | dubbo: 10 | name: dubbo 11 | port: 20000 12 | consumer: 13 | references: 14 | helloService: 15 | protocol: dubbo 16 | interface: org.github.dubbo.HelloService -------------------------------------------------------------------------------- /config/testdata/config/active/application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | profiles: 3 | active: local 4 | registries: 5 | nacos: 6 | timeout: 3s 7 | address: nacos://127.0.0.1:8848 -------------------------------------------------------------------------------- /config/testdata/config/app/application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | timeout: 3s 5 | address: nacos://127.0.0.1:8848 6 | protocols: 7 | dubbo: 8 | name: dubbo 9 | port: 20000 10 | consumer: 11 | references: 12 | helloService: 13 | protocol: dubbo 14 | interface: org.github.dubbo.HelloService # must be compatible with grpc or dubbo-java 15 | provider: 16 | register: true 17 | registry-ids: nacos 18 | services: 19 | helloService: 20 | protocol: dubbo 21 | interface: org.github.dubbo.HelloService # must be compatible with grpc or dubbo-java -------------------------------------------------------------------------------- /config/testdata/config/application/application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | address: nacos://127.0.0.1:8848 -------------------------------------------------------------------------------- /config/testdata/config/center/conf-application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | timeout: 5s 5 | group: dev 6 | address: nacos://127.0.0.1:8848 7 | config-center: 8 | address: nacos://127.0.0.1:8848 9 | cluster: dev 10 | namespace: dubbo 11 | log-dir: ./logs 12 | config-file: dubbo.yaml 13 | app-id: dubbo -------------------------------------------------------------------------------- /config/testdata/config/custom/custom.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | timeout: 5s 5 | group: dev 6 | address: nacos://127.0.0.1:8848 7 | zk: 8 | protocol: zookeeper 9 | group: test 10 | address: 127.0.0.1:2181 11 | custom: 12 | config-map: 13 | test-config: true 14 | -------------------------------------------------------------------------------- /config/testdata/config/custom/empty.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | custom: 3 | registries: 4 | nacos: 5 | timeout: 5s 6 | group: dev 7 | address: nacos://127.0.0.1:8848 8 | zk: 9 | protocol: zookeeper 10 | group: test 11 | address: 127.0.0.1:2181 12 | -------------------------------------------------------------------------------- /config/testdata/config/logger/empty_log.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | logger: 3 | registries: 4 | nacos: 5 | timeout: 5s 6 | group: dev 7 | address: nacos://127.0.0.1:8848 8 | zk: 9 | protocol: zookeeper 10 | group: test 11 | address: 127.0.0.1:2181 -------------------------------------------------------------------------------- /config/testdata/config/logger/file_log.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | timeout: 5s 5 | group: dev 6 | address: nacos://127.0.0.1:8848 7 | zk: 8 | protocol: zookeeper 9 | group: test 10 | address: 127.0.0.1:2181 11 | logger: 12 | logger: 13 | level: debug 14 | driver: logrus 15 | format: text 16 | appender: console,file 17 | file: 18 | name: pandora.log 19 | max-size: 1 20 | max-backups: 2 21 | max-age: 3 22 | compress: true 23 | -------------------------------------------------------------------------------- /config/testdata/config/logger/log.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | timeout: 5s 5 | group: dev 6 | address: nacos://127.0.0.1:8848 7 | zk: 8 | protocol: zookeeper 9 | group: test 10 | address: 127.0.0.1:2181 11 | logger: 12 | zap-config: 13 | level: debug 14 | development: false 15 | disable-caller: false 16 | disable-stacktrace: false 17 | sampling: 18 | encoding: console 19 | # encoder 20 | encoder-config: 21 | message-key: message 22 | level-key: level 23 | time-key: time 24 | name-key: logger 25 | caller-key: caller 26 | stacktrace-key: stacktrace 27 | level-encoder: capitalColor 28 | time-encoder: iso8601 29 | duration-encoder: seconds 30 | caller-encoder: short 31 | name-encoder: 32 | output-paths: 33 | - stderr 34 | error-output-paths: 35 | - stderr 36 | initial-fields: 37 | -------------------------------------------------------------------------------- /config/testdata/config/properties/application.properties: -------------------------------------------------------------------------------- 1 | dubbo.application.name=dubbo-go 2 | dubbo.application.module=local 3 | dubbo.application.version=1.0.0 4 | dubbo.application.owner=zhaoyunxing 5 | dubbo.registries.nacos.protocol=nacos 6 | dubbo.registries.nacos.timeout=5s 7 | dubbo.registries.nacos.address=127.0.0.1:8848 8 | dubbo.registries.zk.protocol=zookeeper 9 | dubbo.registries.zk.timeout=5s 10 | dubbo.registries.zk.group=dev 11 | dubbo.registries.zk.address=127.0.0.1:2181 12 | dubbo.services.HelloService.interface=org.dubbo.service.HelloService 13 | dubbo.services.HelloService.registry=nacos,zk -------------------------------------------------------------------------------- /config/testdata/config/protocol/application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | timeout: 5s 5 | group: dev 6 | address: nacos://127.0.0.1:8848 7 | protocols: 8 | dubbo: 9 | name: dubbo 10 | port: 20000 11 | max-server-send-msg-size: 4mib 12 | max-server-recv-msg-size: 4mib -------------------------------------------------------------------------------- /config/testdata/config/protocol/empty_application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | timeout: 5s 5 | group: dev 6 | address: nacos://127.0.0.1:8848 7 | protocols: -------------------------------------------------------------------------------- /config/testdata/config/provider/application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | timeout: 5s 5 | group: dev 6 | address: nacos://127.0.0.1:8848 7 | provider: 8 | register: true 9 | registry-ids: 10 | - nacos 11 | - zk 12 | services: 13 | helloService: 14 | interface: org.dubbo.service.HelloService 15 | registry-ids: nacos,zk 16 | orderService: 17 | interface: org.dubbo.service.OrderService -------------------------------------------------------------------------------- /config/testdata/config/provider/empty_registry_application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | timeout: 5s 5 | group: dev 6 | address: nacos://127.0.0.1:8848 7 | provider: 8 | register: true -------------------------------------------------------------------------------- /config/testdata/config/provider/registry_application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | timeout: 3s 5 | address: nacos://127.0.0.1:8848 6 | provider: 7 | registry-ids: nacos 8 | services: 9 | HelloService: 10 | interface: org.dubbo.service.HelloService 11 | registry-ids: nacos,zk 12 | OrderService: 13 | interface: org.dubbo.service.OrderService -------------------------------------------------------------------------------- /config/testdata/config/registry/application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | timeout: 5s 5 | group: dev 6 | address: nacos://127.0.0.1:8848 7 | zk: 8 | protocol: zookeeper 9 | group: test 10 | address: 127.0.0.1:2181 -------------------------------------------------------------------------------- /config/testdata/config/registry/empty_application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: -------------------------------------------------------------------------------- /config/testdata/config/resolver/application.yaml: -------------------------------------------------------------------------------- 1 | localhost: 127.0.0.1 2 | dubbo: 3 | application: 4 | name: dubbo-go 5 | module: local 6 | version: 1.0.0 7 | owner: zhaoyunxing 8 | config-center: 9 | address: nacos://127.0.0.1:8848 10 | cluster: dev 11 | namespace: dubbo 12 | log-dir: ./logs 13 | protocols: 14 | dubbo: 15 | name: dubbo 16 | ip: ${localhost} 17 | port: 20000 18 | registries: 19 | nacos: 20 | timeout: 5s 21 | group: ${notexist} 22 | address: ${dubbo.config-center.address:nacos://127.0.0.1:8848} 23 | zk: 24 | protocol: zookeeper 25 | group: ${notexist:dev} 26 | address: 127.0.0.1:2181 27 | services: 28 | helloService: 29 | interface: org.dubbo.service.HelloService 30 | registry-ids: nacos,zk 31 | orderService: 32 | interface: org.dubbo.service.OrderService 33 | registry-ids: nacos 34 | provider: 35 | register: true 36 | services: -------------------------------------------------------------------------------- /config/testdata/consumer_config_with_configcenter.yml: -------------------------------------------------------------------------------- 1 | # dubbo client yaml configure file 2 | 3 | application: 4 | name: "BDTService" 5 | config_center: 6 | protocol: "mock" 7 | address: "127.0.0.1" 8 | references: 9 | "UserProvider": 10 | registry-ids: "hangzhouzk,shanghaizk" 11 | filter: "" 12 | protocol : "dubbo" 13 | interface : "com.ikurento.user.UserProvider" 14 | url: "dubbo://127.0.0.1:20000/UserProvider" 15 | cluster: "failover" 16 | methods : 17 | - name: "GetUser" 18 | retries: "3" 19 | 20 | shutdown_conf: 21 | timeout: 60s 22 | step-timeout: 10s 23 | 24 | protocol_conf: 25 | dubbo: 26 | reconnect_interval: 0 27 | connection_number: 2 28 | heartbeat_period: "5s" 29 | session_timeout: "20s" 30 | pool_size: 64 31 | pool_ttl: 600 32 | getty_session_param: 33 | compress_encoding: false 34 | tcp_no_delay: true 35 | tcp_keep_alive: true 36 | keep_alive_period: "120s" 37 | tcp_r_buf_size: 262144 38 | tcp_w_buf_size: 65536 39 | tcp_read_timeout: "1s" 40 | tcp_write_timeout: "5s" 41 | wait_timeout: "1s" 42 | max_msg_len: 16498688 43 | session_name: "client" 44 | -------------------------------------------------------------------------------- /config/testdata/root_config_test.yml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | demoZK: 4 | protocol: zookeeper 5 | timeout: 11s 6 | address: 127.0.0.1:2181 7 | protocols: 8 | triple: 9 | name: tri 10 | port: 20000 11 | provider: 12 | registry-ids: 13 | - demoZK 14 | services: 15 | GreeterProvider: 16 | protocol-ids: triple 17 | interface: com.apache.dubbo.sample.basic.IGreeter # must be compatible with grpc or dubbo-java 18 | consumer: 19 | request-timeout: 6s 20 | references: 21 | GreeterClientImpl: 22 | protocol: tri 23 | interface: com.apache.dubbo.HelloService # must be compatible with grpc or dubbo-java -------------------------------------------------------------------------------- /config/testdata/router_config_dest_rule.yml: -------------------------------------------------------------------------------- 1 | apiVersion: service.dubbo.apache.org/v1alpha1 2 | kind: DestinationRule 3 | metadata: 4 | name: demo-route 5 | spec: 6 | host: demo 7 | subsets: 8 | - name: v1 9 | labels: 10 | sigma.ali/mg: v1-host 11 | generic: false 12 | - name: v2 13 | labels: 14 | generic: false 15 | - name: v3 16 | labels: 17 | sigma.ali/mg: v3-host -------------------------------------------------------------------------------- /config/tracing_config_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config 19 | 20 | import ( 21 | "testing" 22 | ) 23 | 24 | import ( 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | import ( 29 | "dubbo.apache.org/dubbo-go/v3/common/constant" 30 | ) 31 | 32 | func TestTracingConfig(t *testing.T) { 33 | 34 | tracing := &TracingConfig{} 35 | err := tracing.Init() 36 | assert.Nil(t, err) 37 | assert.Equal(t, tracing.Prefix(), constant.TracingConfigPrefix) 38 | assert.Equal(t, tracing.Name, "jaeger") 39 | assert.Equal(t, *tracing.UseAgent, false) 40 | } 41 | -------------------------------------------------------------------------------- /config_center/base_dynamic_configuration.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config_center 19 | 20 | // BaseDynamicConfiguration will default implementation DynamicConfiguration some method 21 | type BaseDynamicConfiguration struct{} 22 | 23 | func (bdc *BaseDynamicConfiguration) RemoveConfig(string, string) error { 24 | return nil 25 | } 26 | -------------------------------------------------------------------------------- /config_center/configurator.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config_center 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common" 22 | ) 23 | 24 | // Configurator is the interface which wraps GetUrl and Configure method. 25 | type Configurator interface { 26 | GetUrl() *common.URL 27 | Configure(url *common.URL) 28 | } 29 | -------------------------------------------------------------------------------- /config_center/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package config_center provides Config Center definition and implementations for listening service governance rules. 19 | package config_center 20 | -------------------------------------------------------------------------------- /config_center/dynamic_configuration_factory.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package config_center 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common" 22 | ) 23 | 24 | // DynamicConfigurationFactory gets the DynamicConfiguration 25 | type DynamicConfigurationFactory interface { 26 | GetDynamicConfiguration(*common.URL) (DynamicConfiguration, error) 27 | } 28 | -------------------------------------------------------------------------------- /config_center/file/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package file implements config center around file system. 19 | package file 20 | -------------------------------------------------------------------------------- /config_center/nacos/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package nacos implements config center around Nacos. 19 | package nacos 20 | -------------------------------------------------------------------------------- /config_center/zookeeper/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package zookeeper implements config center around zookeeper. 19 | package zookeeper 20 | -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /* 19 | Package dubbo provides the Go implementation for Dubbo, an RPC and microservice framework. 20 | 21 | See dubbo.apache.org for more information about Dubbo. 22 | */ 23 | package dubbo // import "dubbo.apache.org/dubbo-go/v3" 24 | -------------------------------------------------------------------------------- /doc/apache/release_note.md: -------------------------------------------------------------------------------- 1 | ### How to release a new version? 2 | --- 3 | 4 | * 1 Check the time range of NOTICE; 5 | * 2 Pls check the value of Version in common/constant. 6 | * 3 Add the features to the feature list of README.md/README_CN.md/CHANGE.md; 7 | * 4 Check whether every code file has the Apache License 2.0 or not; 8 | * 5 There should not be author info(name & email etc) exist in code file; 9 | * 6 Run all unit tests; 10 | * 7 Run all samples in apache/dubbo-samples/golang; 11 | * 8 Write "What's New" by releaser who should be an apache/dubbo-go committer; 12 | * 9 And then, u can release a new version refer to [Apache 软件发版流程](./apache-release-procedure-20200306.md); -------------------------------------------------------------------------------- /doc/imgs/arc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/arc.png -------------------------------------------------------------------------------- /doc/imgs/invite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/invite.png -------------------------------------------------------------------------------- /doc/imgs/usecase-autohome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-autohome.png -------------------------------------------------------------------------------- /doc/imgs/usecase-beike.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-beike.png -------------------------------------------------------------------------------- /doc/imgs/usecase-eht.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-eht.png -------------------------------------------------------------------------------- /doc/imgs/usecase-gaode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-gaode.png -------------------------------------------------------------------------------- /doc/imgs/usecase-genshuixue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-genshuixue.png -------------------------------------------------------------------------------- /doc/imgs/usecase-jd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-jd.png -------------------------------------------------------------------------------- /doc/imgs/usecase-kaikele.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-kaikele.png -------------------------------------------------------------------------------- /doc/imgs/usecase-mgtv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-mgtv.png -------------------------------------------------------------------------------- /doc/imgs/usecase-mi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-mi.png -------------------------------------------------------------------------------- /doc/imgs/usecase-mosn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-mosn.png -------------------------------------------------------------------------------- /doc/imgs/usecase-pdd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-pdd.png -------------------------------------------------------------------------------- /doc/imgs/usecase-sohu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-sohu.png -------------------------------------------------------------------------------- /doc/imgs/usecase-tianyi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-tianyi.png -------------------------------------------------------------------------------- /doc/imgs/usecase-tiger-brokers.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-tiger-brokers.png -------------------------------------------------------------------------------- /doc/imgs/usecase-tuya.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-tuya.png -------------------------------------------------------------------------------- /doc/imgs/usecase-vivo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-vivo.png -------------------------------------------------------------------------------- /doc/imgs/usecase-xiecheng.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-xiecheng.png -------------------------------------------------------------------------------- /doc/imgs/usecase-zhanzhang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-zhanzhang.png -------------------------------------------------------------------------------- /doc/imgs/usecase-zonghengwenxue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-zonghengwenxue.png -------------------------------------------------------------------------------- /doc/imgs/usecase-zto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/doc/imgs/usecase-zto.png -------------------------------------------------------------------------------- /filter/README.md: -------------------------------------------------------------------------------- 1 | # Filter 2 | 3 | ## Getting Started 4 | 5 | Recommended Way: import what you needs, see also [dubbo-go/imports](https://github.com/dubbogo/imports). 6 | 7 | ```go 8 | package demo 9 | 10 | // use echo and generic filters 11 | import _ "dubbo.apache.org/dubbo-go/v3/filter/echo" 12 | import _ "dubbo.apache.org/dubbo-go/v3/filter/generic" 13 | ``` 14 | 15 | Legacy way: import all filters by one line. 16 | 17 | ```go 18 | package demo 19 | 20 | import _ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl" 21 | ``` 22 | 23 | ## Contents 24 | 25 | - accesslog: Access Log Filter(https://github.com/apache/dubbo-go/pull/214) 26 | - active 27 | - auth: Auth/Sign Filter(https://github.com/apache/dubbo-go/pull/323) 28 | - echo: Echo Health Check Filter 29 | - execlmt: Execute Limit Filter(https://github.com/apache/dubbo-go/pull/246) 30 | - generic: Generic Filter(https://github.com/apache/dubbo-go/pull/291) 31 | - gshutdown: Graceful Shutdown Filter 32 | - hystrix: Hystric Filter(https://github.com/apache/dubbo-go/pull/133) 33 | - metrics: Metrics Filter(https://github.com/apache/dubbo-go/pull/342) 34 | - seata: Seata Filter 35 | - sentinel: Sentinel Filter 36 | - token: Token Filter(https://github.com/apache/dubbo-go/pull/202) 37 | - tps: Tps Limit Filter(https://github.com/apache/dubbo-go/pull/237) 38 | - tracing: Tracing Filter(https://github.com/apache/dubbo-go/pull/335) -------------------------------------------------------------------------------- /filter/adaptivesvc/limiter/utils.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package limiter 19 | 20 | import ( 21 | "time" 22 | ) 23 | 24 | import ( 25 | "github.com/dubbogo/gost/log/logger" 26 | ) 27 | 28 | func VerboseDebugf(msg string, args ...any) { 29 | if !Verbose { 30 | return 31 | } 32 | logger.Debugf(msg, args...) 33 | } 34 | 35 | func minUint64(lhs, rhs uint64) uint64 { 36 | if lhs < rhs { 37 | return lhs 38 | } 39 | return rhs 40 | } 41 | 42 | func minDuration(lhs, rhs time.Duration) time.Duration { 43 | if lhs < rhs { 44 | return lhs 45 | } 46 | return rhs 47 | } 48 | -------------------------------------------------------------------------------- /filter/auth/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package auth providers authorization filter. 19 | package auth 20 | -------------------------------------------------------------------------------- /filter/authenticator.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package filter 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common" 22 | "dubbo.apache.org/dubbo-go/v3/protocol" 23 | ) 24 | 25 | // Authenticator is the interface which defines how an Authenticator works. 26 | // Custom Authenticator must be set by calling auth.SetAuthenticator before use. 27 | type Authenticator interface { 28 | 29 | // Sign adds signature to the invocation 30 | Sign(protocol.Invocation, *common.URL) error 31 | 32 | // Authenticate verifies the signature of the request 33 | Authenticate(protocol.Invocation, *common.URL) error 34 | } 35 | -------------------------------------------------------------------------------- /filter/graceful_shutdown/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package graceful_shutdown provides a filter for shutting down gracefully. 19 | package graceful_shutdown 20 | -------------------------------------------------------------------------------- /filter/handler/rejected_execution_handler_only_log_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package handler 19 | 20 | import ( 21 | "net/url" 22 | "testing" 23 | ) 24 | 25 | import ( 26 | "dubbo.apache.org/dubbo-go/v3/common" 27 | "dubbo.apache.org/dubbo-go/v3/common/constant" 28 | ) 29 | 30 | func TestOnlyLogRejectedExecutionHandler_RejectedExecution(t *testing.T) { 31 | handler := GetOnlyLogRejectedExecutionHandler() 32 | invokeUrl := common.NewURLWithOptions( 33 | common.WithParams(url.Values{}), 34 | common.WithParamsValue(constant.InterfaceKey, "methodName")) 35 | handler.RejectedExecution(invokeUrl, nil) 36 | } 37 | -------------------------------------------------------------------------------- /filter/otel/trace/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package trace instruments dubbogo with open-telemetry 19 | // (https://github.com/open-telemetry/opentelemetry-go). 20 | package trace 21 | -------------------------------------------------------------------------------- /filter/otel/trace/semconv.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package trace 19 | 20 | import ( 21 | "go.opentelemetry.io/otel/attribute" 22 | 23 | semconv "go.opentelemetry.io/otel/semconv/v1.7.0" 24 | ) 25 | 26 | var ( 27 | RPCNameKey = attribute.Key("name") 28 | RPCMessageTypeKey = attribute.Key("message.type") 29 | RPCMessageIDKey = attribute.Key("message.id") 30 | RPCSystemDubbo = semconv.RPCSystemKey.String("apache_dubbo") 31 | RPCNameMessage = RPCNameKey.String("message") 32 | RPCMessageTypeSent = RPCMessageTypeKey.String("SENT") 33 | RPCMessageTypeReceived = RPCMessageTypeKey.String("RECEIVED") 34 | ) 35 | -------------------------------------------------------------------------------- /filter/polaris/limit/default.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package limit 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common/constant" 22 | "dubbo.apache.org/dubbo-go/v3/common/extension" 23 | "dubbo.apache.org/dubbo-go/v3/filter" 24 | ) 25 | 26 | func init() { 27 | extension.SetTpsLimiter(constant.PluginPolarisTpsLimiter, func() filter.TpsLimiter { 28 | return &polarisTpsLimiter{} 29 | }) 30 | } 31 | -------------------------------------------------------------------------------- /global/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package global defines XxxConfigs for collecting Dubbo configurations and is for internal use only. 19 | package global 20 | -------------------------------------------------------------------------------- /global/profiles_config.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package global 19 | 20 | type ProfilesConfig struct { 21 | // active profiles 22 | Active string 23 | } 24 | 25 | func DefaultProfilesConfig() *ProfilesConfig { 26 | return &ProfilesConfig{} 27 | } 28 | 29 | // Clone a new ProfilesConfig 30 | func (c *ProfilesConfig) Clone() *ProfilesConfig { 31 | if c == nil { 32 | return nil 33 | } 34 | 35 | return &ProfilesConfig{ 36 | Active: c.Active, 37 | } 38 | } 39 | 40 | type ProfilesOption func(*ProfilesConfig) 41 | 42 | func WithProfiles_Active(active string) ProfilesOption { 43 | return func(cfg *ProfilesConfig) { 44 | cfg.Active = active 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /global/tracing_config.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package global 19 | 20 | // TracingConfig is the configuration of the tracing. 21 | // Deprecated: it's designed to be replaced with global.OtelConfig 22 | type TracingConfig struct { 23 | Name string `default:"jaeger" yaml:"name" json:"name,omitempty" property:"name"` // jaeger or zipkin(todo) 24 | ServiceName string `yaml:"serviceName" json:"serviceName,omitempty" property:"serviceName"` 25 | Address string `yaml:"address" json:"address,omitempty" property:"address"` 26 | UseAgent *bool `default:"false" yaml:"use-agent" json:"use-agent,omitempty" property:"use-agent"` 27 | } 28 | -------------------------------------------------------------------------------- /graceful_shutdown/graceful_shutdown_signal_darwin.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package graceful_shutdown 19 | 20 | import ( 21 | "os" 22 | "syscall" 23 | ) 24 | 25 | var ( 26 | // ShutdownSignals receives shutdown signals to process 27 | ShutdownSignals = []os.Signal{ 28 | os.Interrupt, os.Kill, syscall.SIGKILL, syscall.SIGSTOP, 29 | syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, 30 | syscall.SIGABRT, syscall.SIGSYS, syscall.SIGTERM, 31 | } 32 | 33 | // DumpHeapShutdownSignals receives shutdown signals to process 34 | DumpHeapShutdownSignals = []os.Signal{ 35 | syscall.SIGQUIT, syscall.SIGILL, 36 | syscall.SIGTRAP, syscall.SIGABRT, syscall.SIGSYS, 37 | } 38 | ) 39 | -------------------------------------------------------------------------------- /graceful_shutdown/graceful_shutdown_signal_windows.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package graceful_shutdown 19 | 20 | import ( 21 | "os" 22 | "syscall" 23 | ) 24 | 25 | var ( 26 | // ShutdownSignals receives shutdown signals to process 27 | ShutdownSignals = []os.Signal{ 28 | os.Interrupt, os.Kill, syscall.SIGKILL, 29 | syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, 30 | syscall.SIGABRT, syscall.SIGTERM, 31 | } 32 | 33 | // DumpHeapShutdownSignals receives shutdown signals to process 34 | DumpHeapShutdownSignals = []os.Signal{syscall.SIGQUIT, syscall.SIGILL, syscall.SIGTRAP, syscall.SIGABRT} 35 | ) 36 | -------------------------------------------------------------------------------- /metadata/report/report_factory.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package report 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common" 22 | ) 23 | 24 | // MetadataReportFactory interface will create metadata report 25 | type MetadataReportFactory interface { 26 | CreateMetadataReport(*common.URL) MetadataReport 27 | } 28 | -------------------------------------------------------------------------------- /metadata/triple_api/proto/java8_time/java8_time.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | syntax = "proto3"; 19 | 20 | package java8_time; 21 | 22 | option go_package = "dubbo.apache.org/dubbo-go/v3/proto/java8_time;java8_time"; 23 | 24 | message Duration{} 25 | 26 | message Instant {} 27 | 28 | message LocalDate{} 29 | 30 | message LocalDateTime{} 31 | 32 | message LocalTime{} 33 | 34 | message MonthDay{} 35 | 36 | message OffsetDateTime{} 37 | 38 | message OffsetTime{} 39 | 40 | message Period{} 41 | 42 | message Year{} 43 | 44 | message YearMonth{} 45 | 46 | message ZoneOffSet{} 47 | 48 | message ZonedDateTime{} -------------------------------------------------------------------------------- /metadata/triple_api/proto/java_math/java_math.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | syntax = "proto3"; 19 | 20 | package java_math; 21 | 22 | option go_package = "dubbo.apache.org/dubbo-go/v3/proto/java_math;java_math"; 23 | 24 | message Decimal {} 25 | 26 | message Integer {} 27 | -------------------------------------------------------------------------------- /metadata/triple_api/proto/java_sql_time/java_sql_time.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | syntax = "proto3"; 19 | 20 | package java_sql_time; 21 | 22 | option go_package = "dubbo.apache.org/dubbo-go/v3/proto/java_sql_time;java_sql_time"; 23 | 24 | message Time {} 25 | 26 | message Date {} -------------------------------------------------------------------------------- /metadata/triple_api/proto/java_util/java_util.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | syntax = "proto3"; 19 | 20 | package java_util; 21 | 22 | option go_package = "dubbo.apache.org/dubbo-go/v3/proto/java_util;java_util"; 23 | 24 | message Locale {} 25 | 26 | message UUID {} -------------------------------------------------------------------------------- /metadata/triple_api/proto/self_extension/self_extension.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package self_extension; 4 | 5 | option go_package = "github.com/apache/dubbo-go-samples/java_interop/non-protobuf-triple/proto/self_extension;self_extension"; 6 | 7 | import "google/protobuf/descriptor.proto"; 8 | import "hessian2_extend/hessian2_extend.proto"; 9 | 10 | message Time { 11 | option (hessian2_extend.message_extend) = { 12 | java_class_name: "java.sql.Time"; 13 | reference_path: "dubbo.apache.org/dubbo-go/v3/proto/java_sql_time"; 14 | }; 15 | } -------------------------------------------------------------------------------- /metrics/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package metrics is for collecting RPC and many other metrics. 19 | package metrics 20 | -------------------------------------------------------------------------------- /metrics/event.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package metrics 19 | 20 | // MetricsEvent represents an event that can be published and subscribed to. 21 | type MetricsEvent interface { 22 | Type() string 23 | } 24 | -------------------------------------------------------------------------------- /otel/trace/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package trace is for collecting tracing data and adapting with backend tracing systems. 19 | package trace 20 | -------------------------------------------------------------------------------- /protocol/dubbo/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package dubbo implements dubbo rpc protocol. 19 | package dubbo 20 | -------------------------------------------------------------------------------- /protocol/dubbo/impl/request.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package impl 19 | 20 | type RequestPayload struct { 21 | Params any 22 | Attachments map[string]any 23 | } 24 | 25 | func NewRequestPayload(args any, atta map[string]any) *RequestPayload { 26 | if atta == nil { 27 | atta = make(map[string]any) 28 | } 29 | return &RequestPayload{ 30 | Params: args, 31 | Attachments: atta, 32 | } 33 | } 34 | 35 | func EnsureRequestPayload(body any) *RequestPayload { 36 | if req, ok := body.(*RequestPayload); ok { 37 | return req 38 | } 39 | return NewRequestPayload(body, nil) 40 | } 41 | -------------------------------------------------------------------------------- /protocol/dubbo/impl/serialize.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package impl 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common/constant" 22 | ) 23 | 24 | type Serializer interface { 25 | Marshal(p DubboPackage) ([]byte, error) 26 | Unmarshal([]byte, *DubboPackage) error 27 | } 28 | 29 | func LoadSerializer(p *DubboPackage) error { 30 | // NOTE: default serialID is S_Hessian 31 | serialID := p.Header.SerialID 32 | if serialID == 0 { 33 | serialID = constant.SHessian2 34 | } 35 | serializer, err := GetSerializerById(serialID) 36 | if err != nil { 37 | panic(err) 38 | } 39 | p.SetSerializer(serializer) 40 | return nil 41 | } 42 | -------------------------------------------------------------------------------- /protocol/dubbo3/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package dubbo3 implements dubbo3.0 rpc protocol. 19 | package dubbo3 20 | -------------------------------------------------------------------------------- /protocol/dubbo3/internal/client.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package internal 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/config" 22 | ) 23 | 24 | func init() { 25 | // for pb client 26 | config.SetConsumerServiceByInterfaceName("org.apache.dubbo.DubboGreeterImpl", &GreeterClientImpl{}) 27 | config.SetConsumerService(&GreeterClientImpl{}) 28 | } 29 | -------------------------------------------------------------------------------- /protocol/grpc/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package grpc implements grpc rpc protocol. 19 | package grpc 20 | -------------------------------------------------------------------------------- /protocol/grpc/internal/README.md: -------------------------------------------------------------------------------- 1 | # internal 2 | 3 | This internal package is for test. So don't use internal in production. 4 | 5 | ## require 6 | 7 | - protoc 8 | - protoc-gen-go: github.com/golang/protobuf/protoc-gen-go@v1.3.0 9 | 10 | ## usage 11 | 12 | - [helloworld](./helloworld): test unary process 13 | - [routeguide](./routeguide): test stream process 14 | - [multiprotos](./multiprotos): use multi pb to generate multi pb.go 15 | -------------------------------------------------------------------------------- /protocol/grpc/internal/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package internal 19 | -------------------------------------------------------------------------------- /protocol/grpc/internal/helloworld/Makefile: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | grpc-gen: 17 | protoc -I ./ helloworld.proto --go_out=plugins=grpc:. 18 | dubbo-gen: 19 | protoc -I ./ helloworld.proto --dubbo_out=plugins=grpc+dubbo:. 20 | -------------------------------------------------------------------------------- /protocol/grpc/internal/multiprotos/Makefile: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | grpc-gen: 17 | protoc -I ./ first.proto second.proto --go_out=plugins=grpc:. 18 | dubbo-gen: 19 | protoc -I ./ first.proto second.proto --dubbo_out=plugins=grpc+dubbo:. 20 | -------------------------------------------------------------------------------- /protocol/grpc/internal/multiprotos/first.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | syntax = "proto3"; 19 | 20 | package multiprotos; 21 | 22 | message FirstRequest { 23 | string message = 1; 24 | } 25 | 26 | message FirstResponse { 27 | string message = 1; 28 | } 29 | 30 | service FristService { 31 | rpc Service (FirstRequest) returns (FirstResponse) {} 32 | } 33 | -------------------------------------------------------------------------------- /protocol/grpc/internal/multiprotos/second.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | syntax = "proto3"; 19 | 20 | package multiprotos; 21 | 22 | message SecondRequest { 23 | string message = 1; 24 | } 25 | 26 | message SecondResponse { 27 | string message = 1; 28 | } 29 | 30 | service SecondService { 31 | rpc Service1 (SecondRequest) returns (SecondResponse) {} 32 | rpc Service2 (SecondRequest) returns (stream SecondResponse) {} 33 | rpc Service3 (stream SecondRequest) returns (SecondResponse) {} 34 | rpc Service4 (stream SecondRequest) returns (stream SecondResponse) {} 35 | } 36 | -------------------------------------------------------------------------------- /protocol/grpc/internal/routeguide/Makefile: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one or more 2 | # contributor license agreements. See the NOTICE file distributed with 3 | # this work for additional information regarding copyright ownership. 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 5 | # (the "License"); you may not use this file except in compliance with 6 | # the License. You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | grpc-gen: 17 | protoc -I ./ routeguide.proto --go_out=plugins=grpc:. 18 | dubbo-gen: 19 | protoc -I ./ routeguide.proto --dubbo_out=plugins=grpc+dubbo:. 20 | -------------------------------------------------------------------------------- /protocol/invoker_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package protocol 19 | 20 | import ( 21 | "testing" 22 | ) 23 | 24 | import ( 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | import ( 29 | "dubbo.apache.org/dubbo-go/v3/common" 30 | ) 31 | 32 | func TestBaseInvoker(t *testing.T) { 33 | url, err := common.NewURL("dubbo://localhost:9090") 34 | assert.Nil(t, err) 35 | 36 | ivk := NewBaseInvoker(url) 37 | assert.NotNil(t, ivk.GetURL()) 38 | assert.True(t, ivk.IsAvailable()) 39 | assert.False(t, ivk.IsDestroyed()) 40 | 41 | ivk.Destroy() 42 | assert.False(t, ivk.IsAvailable()) 43 | assert.True(t, ivk.IsDestroyed()) 44 | } 45 | -------------------------------------------------------------------------------- /protocol/jsonrpc/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package jsonrpc implements json rpc protocol. 19 | package jsonrpc 20 | -------------------------------------------------------------------------------- /protocol/rest/client/rest_client.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package client 19 | 20 | import ( 21 | "net/http" 22 | "time" 23 | ) 24 | 25 | type RestOptions struct { 26 | RequestTimeout time.Duration 27 | ConnectTimeout time.Duration 28 | KeppAliveTimeout time.Duration 29 | } 30 | 31 | type RestClientRequest struct { 32 | Header http.Header 33 | Location string 34 | Path string 35 | Method string 36 | PathParams map[string]string 37 | QueryParams map[string]string 38 | Body any 39 | } 40 | 41 | // RestClient user can implement this client interface to send request 42 | type RestClient interface { 43 | Do(request *RestClientRequest, res any) error 44 | } 45 | -------------------------------------------------------------------------------- /protocol/rest/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package rest implements restful rpc protocol. 19 | package rest 20 | -------------------------------------------------------------------------------- /protocol/triple/common.go: -------------------------------------------------------------------------------- 1 | //go:build go1.19 2 | // +build go1.19 3 | 4 | /* 5 | * Licensed to the Apache Software Foundation (ASF) under one or more 6 | * contributor license agreements. See the NOTICE file distributed with 7 | * this work for additional information regarding copyright ownership. 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 9 | * (the "License"); you may not use this file except in compliance with 10 | * the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | */ 20 | 21 | package triple 22 | 23 | import ( 24 | "net/url" 25 | ) 26 | 27 | func joinProcedure(interfaceName, methodName string) string { 28 | procedure, _ := joinPath("", interfaceName, methodName) 29 | return "/" + procedure 30 | } 31 | 32 | func joinPath(base string, elem ...string) (result string, err error) { 33 | return url.JoinPath(base, elem...) 34 | } 35 | -------------------------------------------------------------------------------- /protocol/triple/triple_protocol/error_example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package triple_protocol_test 16 | 17 | import ( 18 | "errors" 19 | "fmt" 20 | ) 21 | 22 | import ( 23 | tri "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol" 24 | ) 25 | 26 | func ExampleError_Message() { 27 | err := fmt.Errorf( 28 | "another: %w", 29 | tri.NewError(tri.CodeUnavailable, errors.New("failed to foo")), 30 | ) 31 | if connectErr := (&tri.Error{}); errors.As(err, &connectErr) { 32 | fmt.Println("underlying error message:", connectErr.Message()) 33 | } 34 | 35 | // Output: 36 | // underlying error message: failed to foo 37 | } 38 | -------------------------------------------------------------------------------- /protocol/triple/triple_protocol/handler_compat_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package triple_protocol 19 | 20 | import ( 21 | "testing" 22 | ) 23 | 24 | import ( 25 | "github.com/dubbogo/grpc-go/codes" 26 | "github.com/dubbogo/grpc-go/status" 27 | 28 | "github.com/stretchr/testify/assert" 29 | ) 30 | 31 | func TestCompatError(t *testing.T) { 32 | err := status.Error(codes.Code(1234), "user defined") 33 | triErr, ok := compatError(err) 34 | assert.True(t, ok) 35 | assert.Equal(t, Code(1234), triErr.Code()) 36 | assert.Equal(t, "user defined", triErr.Message()) 37 | assert.Equal(t, 1, len(triErr.Details())) 38 | } 39 | -------------------------------------------------------------------------------- /protocol/triple/triple_protocol/header_compat.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package triple_protocol 19 | 20 | // These keys are for compatible usage 21 | const ( 22 | TripleContentType = "application/grpc+proto" 23 | TripleUserAgent = "grpc-go/1.35.0-dev" 24 | TripleServiceVersion = "tri-service-version" 25 | TripleAttachement = "tri-attachment" 26 | TripleServiceGroup = "tri-service-group" 27 | TripleRequestID = "tri-req-id" 28 | TripleTraceID = "tri-trace-traceid" 29 | TripleTraceRPCID = "tri-trace-rpcid" 30 | TripleTraceProtoBin = "tri-trace-proto-bin" 31 | TripleUnitInfo = "tri-unit-info" 32 | ) 33 | -------------------------------------------------------------------------------- /protocol/triple/triple_protocol/internal/interoperability/interop.triple_wrapper.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | // Licensed to the Apache Software Foundation (ASF) under one or more 4 | // contributor license agreements. See the NOTICE file distributed with 5 | // this work for additional information regarding copyright ownership. 6 | // The ASF licenses this file to You under the Apache License, Version 2.0 7 | // (the "License"); you may not use this file except in compliance with 8 | // the License. You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | 18 | package interoperability; 19 | 20 | option go_package = "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol/internal/interoperability;interoperability"; 21 | 22 | 23 | message TripleRequestWrapper { 24 | // hessian4 25 | // json 26 | string serializeType = 1; 27 | repeated bytes args = 2; 28 | repeated string argTypes = 3; 29 | } 30 | 31 | message TripleResponseWrapper { 32 | string serializeType = 1; 33 | bytes data = 2; 34 | string type = 3; 35 | } -------------------------------------------------------------------------------- /protocol/triple/triple_protocol/internal/proto/buf.gen.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | managed: 3 | enabled: true 4 | go_package_prefix: 5 | default: github.com/apache/dubbo-go/protocol/triple/triple_protocol/gen 6 | plugins: 7 | - name: go 8 | out: triple_protocol/gen 9 | opt: paths=source_relative 10 | - name: triple 11 | out: triple_protocol/gen 12 | opt: paths=source_relative 13 | -------------------------------------------------------------------------------- /protocol/triple/triple_protocol/internal/proto/buf.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | lint: 3 | use: 4 | - DEFAULT 5 | ignore: 6 | # We don't control these definitions, so we ignore lint errors. 7 | - connectext/grpc/health/v1/health.proto 8 | - connectext/grpc/reflection/v1alpha/reflection.proto 9 | - connectext/grpc/status/v1/status.proto 10 | breaking: 11 | use: 12 | - WIRE_JSON 13 | -------------------------------------------------------------------------------- /protocol/triple/triple_protocol/internal/proto/connectext/grpc/status/v1/status.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | // This package is for internal use by Connect, and provides no backward 18 | // compatibility guarantees whatsoever. 19 | package grpc.status.v1; 20 | option go_package = "dubbo.apache.org/dubbo-go/v3/protocol/grpc_new/triple/proto/connectext/grpc/status/v1;statusv1"; 21 | 22 | import "google/protobuf/any.proto"; 23 | 24 | // See https://cloud.google.com/apis/design/errors. 25 | // 26 | // This struct must remain binary-compatible with 27 | // https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto. 28 | message Status { 29 | int32 code = 1; // a google.rpc.Code 30 | string message = 2; // developer-facing, English (localize in details or client-side) 31 | repeated google.protobuf.Any details = 3; 32 | } 33 | -------------------------------------------------------------------------------- /protocol/triple/triple_protocol/internal/proto/triple/collide/v1/collide.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | option go_package = "./;v1"; 18 | 19 | package connect.collide.v1; 20 | 21 | message ImportRequest {} 22 | 23 | message ImportResponse {} 24 | 25 | service CollideService { 26 | rpc Import(ImportRequest) returns (ImportResponse) {} 27 | } 28 | -------------------------------------------------------------------------------- /protocol/triple/triple_protocol/internal/proto/triple/import/v1/import.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package connect.import.v1; 18 | 19 | service ImportService {} 20 | -------------------------------------------------------------------------------- /protocol/triple/triple_protocol/internal/testdata/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICmjCCAfygAwIBAgIUGM2+eTbJp3g6o3DPtDQG3tVfL+EwCgYIKoZIzj0EAwIw 3 | XzELMAkGA1UEBhMCVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNh 4 | biBGcmFuY2lzY28xDjAMBgNVBAoMBXJlUlBDMRMwEQYDVQQDDApnaXRodWIuY29t 5 | MB4XDTIxMDczMDIwMTQzM1oXDTMxMDcyODIwMTQzM1owXzELMAkGA1UEBhMCVVMx 6 | EzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xDjAM 7 | BgNVBAoMBXJlUlBDMRMwEQYDVQQDDApnaXRodWIuY29tMIGbMBAGByqGSM49AgEG 8 | BSuBBAAjA4GGAAQA4WPD74+AyZAOxAgWo58oC1JUnFy9Ln3A66rWmDPPprCJhIJ9 9 | i5SyXG1NxwMEIGzyFT3Bp4wWru0ogfpTxPClQ/4Aulrqisiyu4C9Ds1DRJg53E8D 10 | n/CKsQwUYo7MbZIrn63+77kNlJlKloUfBygZ9vQiLjhNA52A95aWRp5yNna/GvCj 11 | UzBRMB0GA1UdDgQWBBRm+gq9izCELNh05BdEH79AWoR9ezAfBgNVHSMEGDAWgBRm 12 | +gq9izCELNh05BdEH79AWoR9ezAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMC 13 | A4GLADCBhwJCAT6Yj94euijggFrKJMcHNV7OZzFkugqiBzOI4OsjA6NfU0UExxBq 14 | VDuUUk2Ek3c4GWYuPvDbdx49Q+zge9Cgl3jYAkF+QrzQWIJHC2L5f5wk8488DBzb 15 | vs0nDV9r+drHM1KDd674y/p2sjY04PQgbNgair+BxjWxCc2QQWGw0SaWDLj/Ag== 16 | -----END CERTIFICATE----- 17 | -------------------------------------------------------------------------------- /protocol/triple/triple_protocol/internal/testdata/server.key: -------------------------------------------------------------------------------- 1 | -----BEGIN EC PARAMETERS----- 2 | BgUrgQQAIw== 3 | -----END EC PARAMETERS----- 4 | -----BEGIN EC PRIVATE KEY----- 5 | MIHcAgEBBEIAN9tRNa4oaevnNxwZEkDTIfbcPlfQP49Q4lapXa1TUXu4Olfu6QyW 6 | ll3OxNIwDg54nsKSuKoaVBOKQelOJjTzyLqgBwYFK4EEACOhgYkDgYYABADhY8Pv 7 | j4DJkA7ECBajnygLUlScXL0ufcDrqtaYM8+msImEgn2LlLJcbU3HAwQgbPIVPcGn 8 | jBau7SiB+lPE8KVD/gC6WuqKyLK7gL0OzUNEmDncTwOf8IqxDBRijsxtkiufrf7v 9 | uQ2UmUqWhR8HKBn29CIuOE0DnYD3lpZGnnI2dr8a8A== 10 | -----END EC PRIVATE KEY----- 11 | -------------------------------------------------------------------------------- /protocol/triple/triple_protocol/protobuf_util.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021-2023 Buf Technologies, Inc. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package triple_protocol 16 | 17 | import ( 18 | "strings" 19 | ) 20 | 21 | // extractProtoPath returns the trailing portion of the URL's path, 22 | // corresponding to the Protobuf package, service, and method. It always starts 23 | // with a slash. Within triple, we use this as (1) Spec.Procedure and (2) the 24 | // path when mounting handlers on muxes. 25 | func extractProtoPath(path string) string { 26 | segments := strings.Split(path, "/") 27 | var pkg, method string 28 | if len(segments) > 0 { 29 | pkg = segments[0] 30 | } 31 | if len(segments) > 1 { 32 | pkg = segments[len(segments)-2] 33 | method = segments[len(segments)-1] 34 | } 35 | if pkg == "" { 36 | return "/" 37 | } 38 | if method == "" { 39 | return "/" + pkg 40 | } 41 | return "/" + pkg + "/" + method 42 | } 43 | -------------------------------------------------------------------------------- /proxy/proxy_factory.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package proxy 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common" 22 | "dubbo.apache.org/dubbo-go/v3/protocol" 23 | ) 24 | 25 | type ProxyFactory interface { 26 | GetProxy(invoker protocol.Invoker, url *common.URL) *Proxy 27 | GetAsyncProxy(invoker protocol.Invoker, callBack any, url *common.URL) *Proxy 28 | GetInvoker(url *common.URL) protocol.Invoker 29 | } 30 | 31 | // Option will define a function of handling ProxyFactory 32 | type Option func(ProxyFactory) 33 | -------------------------------------------------------------------------------- /registry/directory/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package directory implements registry around file system. 19 | package directory 20 | -------------------------------------------------------------------------------- /registry/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package registry defines interfaces to be implemented by service register and service discovery driver. 19 | package registry 20 | -------------------------------------------------------------------------------- /registry/etcdv3/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package etcdv3 implements registry around etcd. 19 | package etcdv3 20 | -------------------------------------------------------------------------------- /registry/nacos/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package nacos implements registry around Nacos. 19 | package nacos 20 | -------------------------------------------------------------------------------- /registry/polaris/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package polaris implements registry around polaris. 19 | package polaris 20 | -------------------------------------------------------------------------------- /registry/registry_factory.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package registry 19 | 20 | // RegistryFactory is the interface that wraps GetRegistries method. 21 | // 22 | // GetRegistries method get all registries. 23 | type RegistryFactory interface { 24 | GetRegistries() []Registry 25 | } 26 | -------------------------------------------------------------------------------- /registry/servicediscovery/instance/service_instance_selector.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package instance 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common" 22 | "dubbo.apache.org/dubbo-go/v3/registry" 23 | ) 24 | 25 | type ServiceInstanceSelector interface { 26 | // Select an instance of ServiceInstance by the specified ServiceInstance service instances 27 | Select(url *common.URL, serviceInstances []registry.ServiceInstance) registry.ServiceInstance 28 | } 29 | -------------------------------------------------------------------------------- /registry/servicediscovery/synthesizer/subscribed_urls_synthesizer.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package synthesizer 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/common" 22 | "dubbo.apache.org/dubbo-go/v3/registry" 23 | ) 24 | 25 | // SubscribedURLsSynthesizer is used to synthesize the subscribed url 26 | type SubscribedURLsSynthesizer interface { 27 | // Supports the synthesis of the subscribed url or not 28 | Support(subscribedURL *common.URL) bool 29 | // synthesize the subscribed url 30 | Synthesize(subscribedURL *common.URL, serviceInstances []registry.ServiceInstance) []*common.URL 31 | } 32 | -------------------------------------------------------------------------------- /registry/servicediscovery/synthesizer/subscribed_urls_synthesizer_factory.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package synthesizer 19 | 20 | import ( 21 | "sync" 22 | ) 23 | 24 | var ( 25 | synthesizers []SubscribedURLsSynthesizer 26 | synthesizerMutex sync.RWMutex 27 | ) 28 | 29 | // nolint 30 | func AddSynthesizer(synthesizer SubscribedURLsSynthesizer) { 31 | synthesizerMutex.Lock() 32 | defer synthesizerMutex.Unlock() 33 | synthesizers = append(synthesizers, synthesizer) 34 | } 35 | 36 | // nolint 37 | func GetAllSynthesizer() []SubscribedURLsSynthesizer { 38 | synthesizerMutex.RLock() 39 | defer synthesizerMutex.RUnlock() 40 | return synthesizers 41 | } 42 | -------------------------------------------------------------------------------- /registry/zookeeper/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package zookeeper implements registry around zookeeper. 19 | package zookeeper 20 | -------------------------------------------------------------------------------- /remoting/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // Package remoting provides facilities for decoding and encoding, client and server. 19 | package remoting 20 | -------------------------------------------------------------------------------- /remoting/getty/getty_server_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package getty 19 | 20 | import ( 21 | "testing" 22 | ) 23 | 24 | import ( 25 | "github.com/stretchr/testify/assert" 26 | ) 27 | 28 | import ( 29 | "dubbo.apache.org/dubbo-go/v3/config" 30 | ) 31 | 32 | func TestInitServer(t *testing.T) { 33 | originRootConf := config.GetRootConfig() 34 | rootConf := config.RootConfig{ 35 | Protocols: map[string]*config.ProtocolConfig{ 36 | "dubbo": { 37 | Name: "dubbo", 38 | Ip: "127.0.0.1", 39 | Port: "20003", 40 | }, 41 | }, 42 | } 43 | config.SetRootConfig(rootConf) 44 | initServer("dubbo") 45 | config.SetRootConfig(*originRootConf) 46 | assert.NotNil(t, srvConf) 47 | } 48 | -------------------------------------------------------------------------------- /remoting/zookeeper/listener_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package zookeeper 19 | 20 | import ( 21 | "net/url" 22 | "testing" 23 | ) 24 | 25 | import ( 26 | "github.com/stretchr/testify/assert" 27 | ) 28 | 29 | func TestZkPath(t *testing.T) { 30 | zkPath := "io.grpc.examples.helloworld.GreeterGrpc$IGreeter" 31 | zkPath = url.QueryEscape(zkPath) 32 | assert.Equal(t, zkPath, "io.grpc.examples.helloworld.GreeterGrpc%24IGreeter") 33 | } 34 | -------------------------------------------------------------------------------- /tools/dubbo-go-schema/README.md: -------------------------------------------------------------------------------- 1 | # dubbo-go-schema 2 | 这个项目为了便捷的编写dubbo-go配置文件 3 | 4 | ## 怎么使用 5 | 6 | ### golang 7 | 8 | > [dubbo-go.json](./dubbo-go.json) 9 | 10 | ![img.png](images/img.png) 11 | 12 | ### vs code 13 | 14 | ![vs-code](images/vs-code.png) 15 | 16 | 在 settings.json 文件添加 17 | ```json 18 | { 19 | "yaml.schemas": { 20 | "https://dubbogo.github.io/dubbo-go-schema/dubbo-go.json": [ 21 | "dubbo.yaml", 22 | "application.yaml", 23 | "dubbogo.yaml" 24 | ] 25 | } 26 | } 27 | 28 | ``` 29 | ## 效果图 30 | 31 | ![img_1.png](images/img_1.png) 32 | -------------------------------------------------------------------------------- /tools/dubbo-go-schema/application.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | timeout: 5s 5 | registry-type: service 6 | protocol: nacos 7 | protocols: 8 | dubbo: 9 | name: dubbo 10 | provider: 11 | services: 12 | userService: 13 | protocol-ids: 14 | - dubbo 15 | loadbalance: random 16 | consumer: 17 | references: 18 | dddd: 19 | filter: dddd 20 | interface: ddddd 21 | timeout: dd 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /tools/dubbo-go-schema/images/img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/tools/dubbo-go-schema/images/img.png -------------------------------------------------------------------------------- /tools/dubbo-go-schema/images/img_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/tools/dubbo-go-schema/images/img_1.png -------------------------------------------------------------------------------- /tools/dubbo-go-schema/images/vs-code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/dubbo-go/0ba792a48728b278c910fabb251d0a82e96e9bae/tools/dubbo-go-schema/images/vs-code.png -------------------------------------------------------------------------------- /tools/dubbogo-cli/Makefile: -------------------------------------------------------------------------------- 1 | test: 2 | go test ./... -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newApp/.gitignore: -------------------------------------------------------------------------------- 1 | ./build/!Dockerfile 2 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newApp/Makefile: -------------------------------------------------------------------------------- 1 | IMAGE = $(your_repo)/$(namespace)/$(image_name) 2 | TAG = 1.0.0 3 | HELM_INSTALL_NAME = dubbo-go-app 4 | 5 | build-amd64-app: 6 | GOOS=linux GOARCH=amd64 go build -o build/app ./cmd 7 | 8 | build: proto-gen tidy build-amd64-app 9 | cp ./conf/dubbogo.yaml ./build/dubbogo.yaml 10 | docker build ./build -t ${IMAGE}:${TAG} 11 | docker push ${IMAGE}:${TAG} 12 | make clean 13 | 14 | buildx-publish: proto-gen tidy build-amd64-app 15 | cp ./conf/dubbogo.yaml ./build/dubbogo.yaml 16 | docker buildx build \ 17 | --platform linux/amd64 \ 18 | -t ${IMAGE}:${TAG} \ 19 | ./build --push 20 | make clean 21 | 22 | remove: 23 | helm uninstall ${HELM_INSTALL_NAME} 24 | 25 | deploy: 26 | helm install ${HELM_INSTALL_NAME} ./chart/app 27 | 28 | deploy-nacos-env: 29 | helm install nacos ./chart/nacos_env 30 | 31 | remove-nacos-env: 32 | helm uninstall nacos 33 | 34 | proto-gen: 35 | protoc --go_out=./api --go-triple_out=./api ./api/api.proto 36 | 37 | clean: 38 | rm ./build/dubbogo.yaml 39 | rm ./build/app 40 | 41 | tidy: 42 | go mod tidy 43 | 44 | test: 45 | go test ./... 46 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newApp/build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.15 2 | 3 | WORKDIR /dubbogo 4 | 5 | ENV DUBBO_GO_CONFIG_PATH=/dubbogo/dubbogo.yaml 6 | 7 | COPY ./app /dubbogo/app 8 | COPY ./dubbogo.yaml /dubbogo/dubbogo.yaml 9 | 10 | CMD /dubbogo/app 11 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newApp/chart/app/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | name: dubbo-go-app 3 | description: dubbo-go-app 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | # Versions are expected to follow Semantic Versioning (https://semver.org/) 18 | version: 0.0.1 19 | 20 | # This is the version number of the application being deployed. This version number should be 21 | # incremented each time you make changes to the application. Versions are not expected to 22 | # follow Semantic Versioning. They should reflect the version the application is using. 23 | # It is recommended to use it with quotes. 24 | appVersion: "1.16.0" 25 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newApp/chart/app/templates/service.yaml: -------------------------------------------------------------------------------- 1 | # Dubbo-go version control, we do not update service if there is exsiting service, because 2 | # service is an app-level resource, helm install service with a different helmName again to add an app 3 | # version would cause failed. 4 | {{- $svc := lookup "v1" "Service" .Release.Namespace .Chart.Name }} 5 | {{- if not $svc }} 6 | apiVersion: v1 7 | kind: Service 8 | metadata: 9 | name: {{ include "app.name" . }} 10 | labels: 11 | {{- include "app.labels" . | nindent 4 }} 12 | spec: 13 | type: {{ .Values.service.type }} 14 | ports: 15 | - port: {{ .Values.service.port }} 16 | targetPort: {{ .Values.service.portName }} 17 | protocol: TCP 18 | name: {{ .Values.service.portName }} 19 | selector: 20 | {{- include "app.selectorLabels" . | nindent 4 }} 21 | {{- end }} 22 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newApp/chart/app/templates/serviceaccount.yaml: -------------------------------------------------------------------------------- 1 | {{- if .Values.serviceAccount.create -}} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: {{ include "app.serviceAccountName" . }} 6 | labels: 7 | {{- include "app.labels" . | nindent 4 }} 8 | {{- with .Values.serviceAccount.annotations }} 9 | annotations: 10 | {{- toYaml . | nindent 4 }} 11 | {{- end }} 12 | {{- end }} 13 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newApp/chart/nacos_env/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | name: nacos 3 | description: nacos environment 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | # Versions are expected to follow Semantic Versioning (https://semver.org/) 18 | version: 0.0.1 19 | 20 | # This is the version number of the application being deployed. This version number should be 21 | # incremented each time you make changes to the application. Versions are not expected to 22 | # follow Semantic Versioning. They should reflect the version the application is using. 23 | # It is recommended to use it with quotes. 24 | appVersion: "1.16.0" 25 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newApp/chart/nacos_env/templates/service.yaml: -------------------------------------------------------------------------------- 1 | # Dubbo-go version control, we do not update service if there is exsiting service, because 2 | # service is an app-level resource, helm install service with a different helmName again to add an app 3 | # version would cause failed. 4 | {{- $svc := lookup "v1" "Service" .Release.Namespace .Chart.Name }} 5 | {{- if not $svc }} 6 | apiVersion: v1 7 | kind: Service 8 | metadata: 9 | name: {{ include "app.name" . }} 10 | labels: 11 | {{- include "app.labels" . | nindent 4 }} 12 | spec: 13 | type: {{ .Values.service.type }} 14 | ports: 15 | - port: {{ .Values.service.port }} 16 | targetPort: {{ .Values.service.portName }} 17 | protocol: TCP 18 | name: {{ .Values.service.portName }} 19 | selector: 20 | {{- include "app.selectorLabels" . | nindent 4 }} 21 | {{- end }} 22 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newApp/chart/nacos_env/values.yaml: -------------------------------------------------------------------------------- 1 | replicaCount: 1 2 | 3 | image: 4 | repository: nacos/nacos-server 5 | pullPolicy: IfNotPresent 6 | tag: "2.0.1" 7 | 8 | version: 9 | labels: 10 | dubbogoAppVersion: latest 11 | 12 | container: 13 | env: 14 | - name: MODE 15 | value: "standalone" 16 | ports: 17 | - name: http 18 | containerPort: 8848 19 | protocol: TCP 20 | 21 | 22 | imagePullSecrets: [] 23 | nameOverride: "" 24 | fullnameOverride: "" 25 | 26 | serviceAccount: 27 | # Specifies whether a service account should be created 28 | create: true 29 | # Annotations to add to the service account 30 | annotations: {} 31 | # The name of the service account to use. 32 | # If not set and create is true, a name is generated using the fullname template 33 | name: "" 34 | 35 | podAnnotations: {} 36 | 37 | podSecurityContext: {} 38 | # fsGroup: 2000 39 | 40 | securityContext: {} 41 | # capabilities: 42 | # drop: 43 | # - ALL 44 | # readOnlyRootFilesystem: true 45 | # runAsNonRoot: true 46 | # runAsUser: 1000 47 | 48 | service: 49 | type: ClusterIP 50 | port: 8848 51 | portName: http 52 | 53 | nodeSelector: {} 54 | 55 | tolerations: [] 56 | 57 | affinity: {} 58 | 59 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newApp/cmd/app.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package main 19 | 20 | import ( 21 | _ "dubbo-go-app/pkg/service" 22 | ) 23 | 24 | import ( 25 | "dubbo.apache.org/dubbo-go/v3/config" 26 | _ "dubbo.apache.org/dubbo-go/v3/imports" 27 | ) 28 | 29 | // export DUBBO_GO_CONFIG_PATH=$PATH_TO_APP/conf/dubbogo.yaml 30 | func main() { 31 | if err := config.Load(); err != nil { 32 | panic(err) 33 | } 34 | select {} 35 | } 36 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newApp/conf/dubbogo.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | registries: 3 | nacos: 4 | protocol: nacos 5 | address: nacos:8848 6 | protocols: 7 | triple: 8 | name: tri 9 | port: 20000 10 | provider: 11 | services: 12 | GreeterServerImpl: 13 | interface: "" # read from stub 14 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newDemo/api/samples_api.proto: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | syntax = "proto3"; 19 | package api; 20 | 21 | option go_package = "./;api"; 22 | 23 | // The greeting service definition. 24 | service Greeter { 25 | // Sends a greeting 26 | rpc SayHello (HelloRequest) returns (User) {} 27 | // Sends a greeting via stream 28 | rpc SayHelloStream (stream HelloRequest) returns (stream User) {} 29 | } 30 | 31 | // The request message containing the user's name. 32 | message HelloRequest { 33 | string name = 1; 34 | } 35 | 36 | // The response message containing the greetings 37 | message User { 38 | string name = 1; 39 | string id = 2; 40 | int32 age = 3; 41 | } -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newDemo/go-client/conf/dubbogo.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | consumer: 3 | references: 4 | GreeterClientImpl: 5 | protocol: tri 6 | url: "tri://localhost:20000" 7 | interface: "" # read from pb -------------------------------------------------------------------------------- /tools/dubbogo-cli/cmd/testGenCode/template/newDemo/go-server/conf/dubbogo.yaml: -------------------------------------------------------------------------------- 1 | dubbo: 2 | protocols: 3 | triple: 4 | name: tri 5 | port: 20000 6 | provider: 7 | services: 8 | GreeterProvider: 9 | interface: "" # read from pb -------------------------------------------------------------------------------- /tools/dubbogo-cli/constant/constant.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package constant 19 | 20 | const ( 21 | Version = "1.0.0" 22 | ) 23 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/generator/application/build.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package application 19 | 20 | const ( 21 | dockerFile = `FROM alpine:3.15 22 | 23 | WORKDIR /dubbogo 24 | 25 | ENV DUBBO_GO_CONFIG_PATH=/dubbogo/dubbogo.yaml 26 | 27 | COPY ./app /dubbogo/app 28 | COPY ./dubbogo.yaml /dubbogo/dubbogo.yaml 29 | 30 | CMD /dubbogo/app 31 | ` 32 | ) 33 | 34 | func init() { 35 | fileMap["dockerfile"] = &fileGenerator{ 36 | path: "./build", 37 | file: "Dockerfile", 38 | context: dockerFile, 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/generator/application/cmd.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package application 19 | 20 | const ( 21 | appGoFile = `package main 22 | 23 | import ( 24 | _ "dubbo-go-app/pkg/service" 25 | 26 | "dubbo.apache.org/dubbo-go/v3/config" 27 | _ "dubbo.apache.org/dubbo-go/v3/imports" 28 | ) 29 | 30 | // export DUBBO_GO_CONFIG_PATH=$PATH_TO_APP/conf/dubbogo.yaml 31 | func main() { 32 | if err := config.Load(); err != nil { 33 | panic(err) 34 | } 35 | select {} 36 | } 37 | 38 | ` 39 | ) 40 | 41 | func init() { 42 | fileMap["appGoFile"] = &fileGenerator{ 43 | path: "./cmd", 44 | file: "app.go", 45 | context: appGoFile, 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/generator/application/conf.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package application 19 | 20 | const ( 21 | configFile = `dubbo: 22 | registries: 23 | nacos: 24 | protocol: nacos 25 | address: nacos:8848 26 | protocols: 27 | triple: 28 | name: tri 29 | port: 20000 30 | provider: 31 | services: 32 | GreeterServerImpl: 33 | interface: "" # read from stub 34 | ` 35 | ) 36 | 37 | func init() { 38 | fileMap["configFile"] = &fileGenerator{ 39 | path: "./conf", 40 | file: "dubbogo.yaml", 41 | context: configFile, 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/generator/application/gitignore.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package application 19 | 20 | const ( 21 | gitignoreFile = `./build/!Dockerfile 22 | ` 23 | ) 24 | 25 | func init() { 26 | fileMap["gitignoreFile"] = &fileGenerator{ 27 | path: ".", 28 | file: ".gitignore", 29 | context: gitignoreFile, 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/generator/application/gomod.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package application 19 | 20 | const ( 21 | gomodFile = `module dubbo-go-app 22 | 23 | go 1.17 24 | 25 | require ( 26 | dubbo.apache.org/dubbo-go/v3 v3.0.1 27 | github.com/dubbogo/grpc-go v1.42.9 28 | github.com/dubbogo/triple v1.1.8 29 | github.com/golang/protobuf v1.5.2 30 | google.golang.org/protobuf v1.27.1 31 | ) 32 | ` 33 | ) 34 | 35 | func init() { 36 | fileMap["gomodFile"] = &fileGenerator{ 37 | path: ".", 38 | file: "go.mod", 39 | context: gomodFile, 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/generator/sample/gen_c_conf.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package sample 19 | 20 | const ( 21 | clientConfigFile = `dubbo: 22 | consumer: 23 | references: 24 | GreeterClientImpl: 25 | protocol: tri 26 | url: "tri://localhost:20000" 27 | interface: "" # read from pb` 28 | ) 29 | 30 | func init() { 31 | fileMap["clientConfigFile"] = &fileGenerator{ 32 | path: "./go-client/conf", 33 | file: "dubbogo.yaml", 34 | context: clientConfigFile, 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/generator/sample/gen_s_conf.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package sample 19 | 20 | const ( 21 | serverConfigFile = `dubbo: 22 | protocols: 23 | triple: 24 | name: tri 25 | port: 20000 26 | provider: 27 | services: 28 | GreeterProvider: 29 | interface: "" # read from pb` 30 | ) 31 | 32 | func init() { 33 | fileMap["srvConfGenerator"] = &fileGenerator{ 34 | path: "./go-server/conf", 35 | file: "dubbogo.yaml", 36 | context: serverConfigFile, 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/generator/sample/hessian/logger.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package hessian 19 | 20 | import ( 21 | "log" 22 | ) 23 | 24 | type logType int 25 | 26 | const ( 27 | infoLog logType = iota 28 | errorLog 29 | ) 30 | 31 | var _onlyError = false 32 | 33 | // showLog 输出日志 34 | func showLog(t logType, format string, v ...any) { 35 | format = format + "\n" 36 | if t == errorLog { 37 | log.Fatalf(format, v...) 38 | return 39 | } 40 | if _onlyError { 41 | return 42 | } 43 | log.Printf(format, v...) 44 | } 45 | 46 | func ToggleLog(onlyError bool) { 47 | _onlyError = onlyError 48 | } 49 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/generator/sample/hessian/pool.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package hessian 19 | 20 | import ( 21 | "sync" 22 | ) 23 | 24 | // Task 任务 25 | type Task interface { 26 | Execute() 27 | } 28 | 29 | // Pool 线程池 30 | type Pool struct { 31 | wg *sync.WaitGroup 32 | 33 | taskQueue chan Task 34 | } 35 | 36 | func NewPool(max int) *Pool { 37 | return &Pool{ 38 | wg: &sync.WaitGroup{}, 39 | taskQueue: make(chan Task, max), 40 | } 41 | } 42 | 43 | func (p Pool) Execute(t Task) { 44 | p.wg.Add(1) 45 | p.taskQueue <- t 46 | go func() { 47 | t.Execute() 48 | <-p.taskQueue 49 | p.wg.Done() 50 | }() 51 | } 52 | 53 | func (p Pool) Wait() { 54 | p.wg.Wait() 55 | } 56 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/generator/sample/hessian_generator.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package sample 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/tools/dubbogo-cli/generator/sample/hessian" 22 | ) 23 | 24 | func HessianRegistryGenerate(includePath string, threadMax int, onlyError bool) error { 25 | hessian.ToggleLog(onlyError) 26 | 27 | fileList, err := hessian.ListFiles(includePath, hessian.TargetFileSuffix) 28 | if err != nil { 29 | return err 30 | } 31 | 32 | pool := hessian.NewPool(threadMax) 33 | for _, f := range fileList { 34 | pool.Execute(hessian.NewGenerator(f)) 35 | } 36 | pool.Wait() 37 | return nil 38 | } 39 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/generator/sample/mod.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package sample 19 | 20 | const ( 21 | modFile = `module helloworld 22 | 23 | go 1.17 24 | 25 | require ( 26 | dubbo.apache.org/dubbo-go/v3 v3.0.1 27 | github.com/dubbogo/grpc-go v1.42.9 28 | github.com/dubbogo/triple v1.1.8 29 | google.golang.org/protobuf v1.27.1 30 | ) 31 | ` 32 | ) 33 | 34 | func init() { 35 | fileMap["modFile"] = &fileGenerator{ 36 | path: "./", 37 | file: "go.mod", 38 | context: modFile, 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/internal/common/protocol.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package common 19 | 20 | import ( 21 | "dubbo.apache.org/dubbo-go/v3/tools/dubbogo-cli/internal/protocol" 22 | ) 23 | 24 | var protocols = make(map[string]func() protocol.Protocol, 8) 25 | 26 | // SetProtocol sets the protocol extension with @name 27 | func SetProtocol(name string, v func() protocol.Protocol) { 28 | protocols[name] = v 29 | } 30 | 31 | // GetProtocol finds the protocol extension with @name 32 | func GetProtocol(name string) protocol.Protocol { 33 | if protocols[name] == nil { 34 | panic("protocol for " + name + " is not existing, make sure you have import the package.") 35 | } 36 | return protocols[name]() 37 | } 38 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/internal/common/tool.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package common 19 | 20 | import ( 21 | "fmt" 22 | "log" 23 | "reflect" 24 | ) 25 | 26 | // PrintInterface print the interface by level 27 | func PrintInterface(v any) { 28 | val := reflect.ValueOf(v).Elem() 29 | typ := reflect.TypeOf(v) 30 | log.Printf("%+v\n", v) 31 | nums := val.NumField() 32 | for i := 0; i < nums; i++ { 33 | if typ.Elem().Field(i).Type.Kind() == reflect.Ptr { 34 | log.Printf("%s: ", typ.Elem().Field(i).Name) 35 | PrintInterface(val.Field(i).Interface()) 36 | } 37 | } 38 | fmt.Println("") 39 | } 40 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/internal/protocol/protocol.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package protocol 19 | 20 | import ( 21 | "sync" 22 | ) 23 | 24 | type Protocol interface { 25 | Read([]byte, *sync.Map) (any, int, error) 26 | Write(*Request) ([]byte, error) 27 | } 28 | 29 | type Request struct { 30 | ID uint64 31 | InterfaceID string // interface寻址id 32 | Version string 33 | Group string 34 | Method string 35 | Params any 36 | } 37 | -------------------------------------------------------------------------------- /tools/dubbogo-cli/main.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | // dubbogo-cli is a cli tool for initializing dubbo-go project, test service, etc. 19 | // 20 | // Deprecated: github.com/apache/dubbo-kubernetes will serve as the successor of this tool 21 | package main 22 | 23 | import ( 24 | "dubbo.apache.org/dubbo-go/v3/tools/dubbogo-cli/cmd" 25 | ) 26 | 27 | func main() { 28 | cmd.Execute() 29 | } 30 | --------------------------------------------------------------------------------