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 ServiceNaming
Returns theServiceNaming
that returns the full name of an RPC stub class or the innermost class from the given service.static ServiceNaming
Returns theServiceNaming
that 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 ServiceNaming
shorten()
Returns theServiceNaming
that returns the shortened service name from the full name of an RPC stub class or the innermost class from the given service.static ServiceNaming
shorten
(int targetLength) Returns theServiceNaming
that returns the shortened service name from the full name of an RPC stub class or the innermost class from the given service.static ServiceNaming
Returns theServiceNaming
that returns the simple name of an RPC stub class or the innermost class from the given service.
-
Method Details
-
of
Returns theServiceNaming
that always returns the given hard-coded service name. -
fullTypeName
Returns theServiceNaming
that 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 theServiceNaming
that 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 theServiceNaming
that 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.HelloService
is able to be shorten toc.f.b.HelloService
.- See Also:
-
shorten
Returns theServiceNaming
that 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.HelloService
is 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
null
is 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$AsyncIface
orcom.foo.ThriftService$Iface
) HttpService
and 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,
-