Package com.linecorp.armeria.server
Interface ServiceNaming
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Generates the default name of a
Service from its ServiceRequestContext.-
Method Summary
Modifier and TypeMethodDescriptionstatic ServiceNamingReturns theServiceNamingthat returns the full name of an RPC stub class or the innermost class from the given service.static ServiceNamingReturns theServiceNamingthat always returns the given hard-coded service name.Converts the specified serviceName into another service name which is used as a meter tag or distributed trace's span name.static ServiceNamingshorten()Returns theServiceNamingthat returns the shortened service name from the full name of an RPC stub class or the innermost class from the given service.static ServiceNamingshorten(int targetLength) Returns theServiceNamingthat returns the shortened service name from the full name of an RPC stub class or the innermost class from the given service.static ServiceNamingReturns theServiceNamingthat returns the simple name of an RPC stub class or the innermost class from the given service.
-
Method Details
-
of
Returns theServiceNamingthat always returns the given hard-coded service name. -
fullTypeName
Returns theServiceNamingthat returns the full name of an RPC stub class or the innermost class from the given service. It will be fully qualified name including the package name separated by a period. e.g.com.foo.HelloService.- See Also:
-
simpleTypeName
Returns theServiceNamingthat returns the simple name of an RPC stub class or the innermost class from the given service. It is supposed to have a class name without a period. e.g.HelloService. -
shorten
Returns theServiceNamingthat returns the shortened service name from the full name of an RPC stub class or the innermost class from the given service. It follows Logback's abbreviation algorithm. Please note that the rightmost segment in a service name is never abbreviated. For instance,com.foo.bar.HelloServiceis able to be shorten toc.f.b.HelloService.- See Also:
-
shorten
Returns theServiceNamingthat returns the shortened service name from the full name of an RPC stub class or the innermost class from the given service. It follows Logback's abbreviation algorithm. Please note that the rightmost segment in a service name is only left and other segments are abbreviated to a letter. For instance,com.foo.bar.HelloServiceis able to be shorten toc.f.b.HelloService.- See Also:
-
serviceName
Converts the specified serviceName into another service name which is used as a meter tag or distributed trace's span name.If
nullis returned, one of the following values will be used instead:- gRPC - a service name (e.g,
com.foo.GrpcService) - Thrift - a service type (e.g,
com.foo.ThriftService$AsyncIfaceorcom.foo.ThriftService$Iface) HttpServiceand annotated service - an innermost class name
A naming rule can be set by either
ServerBuilder.defaultServiceNaming(ServiceNaming)orServiceBindingBuilder.defaultServiceNaming(ServiceNaming). One of pre-defined naming rules is able to be used as follows.Example
Server server = Server.builder() .service(...) .defaultServiceNaming(ServiceNaming.simpleTypeName()) .build()Example 2
Server server = Server.builder() .route().path("/") .defaultServiceNaming(ServiceNaming.fullTypeName()) ... .build()If customizing is needed out of given rules, a lambda expression would be applied as follows.
Server server = Server.builder() .service(...) .defaultServiceNaming(ctx -> { final ServiceConfig config = ctx.config(); return config.server().defaultHostname() + config.route().patternString(); }) .build() - gRPC - a service name (e.g,
-