Java Code Examples for io.grpc.ServiceDescriptor#getMethods()

The following examples show how to use io.grpc.ServiceDescriptor#getMethods() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GrpcServerMetricAutoConfiguration.java    From grpc-spring-boot-starter with MIT License 5 votes vote down vote up
/**
 * Gets all method names from the given service descriptor.
 *
 * @param serviceDescriptor The service descriptor to get the names from.
 * @return The newly created and sorted list of the method names.
 */
protected List<String> collectMethodNamesForService(final ServiceDescriptor serviceDescriptor) {
    final List<String> methods = new ArrayList<>();
    for (final MethodDescriptor<?, ?> grpcMethod : serviceDescriptor.getMethods()) {
        methods.add(extractMethodName(grpcMethod));
    }
    methods.sort(String.CASE_INSENSITIVE_ORDER);
    return methods;
}
 
Example 2
Source File: GrpcServerMetricAutoConfiguration.java    From grpc-spring-boot-starter with MIT License 5 votes vote down vote up
/**
 * Gets all method names from the given service descriptor.
 *
 * @param serviceDescriptor The service descriptor to get the names from.
 * @return The newly created and sorted list of the method names.
 */
protected List<String> collectMethodNamesForService(final ServiceDescriptor serviceDescriptor) {
    final List<String> methods = new ArrayList<>();
    for (final MethodDescriptor<?, ?> grpcMethod : serviceDescriptor.getMethods()) {
        methods.add(extractMethodName(grpcMethod));
    }
    methods.sort(String.CASE_INSENSITIVE_ORDER);
    return methods;
}
 
Example 3
Source File: ManualGrpcSecurityMetadataSource.java    From grpc-spring-boot-starter with MIT License 3 votes vote down vote up
/**
 * Set the given access predicate for the all methods of the given service. This will replace previously set
 * predicates.
 *
 * @param service The service to protect with a custom check.
 * @param predicate The predicate used to check the {@link Authentication}.
 * @return This instance for chaining.
 * @see #setDefault(AccessPredicate)
 */
public ManualGrpcSecurityMetadataSource set(final ServiceDescriptor service, final AccessPredicate predicate) {
    requireNonNull(service, "service");
    final Collection<ConfigAttribute> wrappedPredicate = wrap(predicate);
    for (final MethodDescriptor<?, ?> method : service.getMethods()) {
        this.accessMap.put(method, wrappedPredicate);
    }
    return this;
}
 
Example 4
Source File: ManualGrpcSecurityMetadataSource.java    From grpc-spring-boot-starter with MIT License 3 votes vote down vote up
/**
 * Removes all access predicates for the all methods of the given service. After that, the default will be used for
 * those methods.
 *
 * @param service The service to protect with only the default.
 * @return This instance for chaining.
 * @see #setDefault(AccessPredicate)
 */
public ManualGrpcSecurityMetadataSource remove(final ServiceDescriptor service) {
    requireNonNull(service, "service");
    for (final MethodDescriptor<?, ?> method : service.getMethods()) {
        this.accessMap.remove(method);
    }
    return this;
}
 
Example 5
Source File: ManualGrpcSecurityMetadataSource.java    From grpc-spring-boot-starter with MIT License 3 votes vote down vote up
/**
 * Set the given access predicate for the all methods of the given service. This will replace previously set
 * predicates.
 *
 * @param service The service to protect with a custom check.
 * @param predicate The predicate used to check the {@link Authentication}.
 * @return This instance for chaining.
 * @see #setDefault(AccessPredicate)
 */
public ManualGrpcSecurityMetadataSource set(final ServiceDescriptor service, final AccessPredicate predicate) {
    requireNonNull(service, "service");
    final Collection<ConfigAttribute> wrappedPredicate = wrap(predicate);
    for (final MethodDescriptor<?, ?> method : service.getMethods()) {
        this.accessMap.put(method, wrappedPredicate);
    }
    return this;
}
 
Example 6
Source File: ManualGrpcSecurityMetadataSource.java    From grpc-spring-boot-starter with MIT License 3 votes vote down vote up
/**
 * Removes all access predicates for the all methods of the given service. After that, the default will be used for
 * those methods.
 *
 * @param service The service to protect with only the default.
 * @return This instance for chaining.
 * @see #setDefault(AccessPredicate)
 */
public ManualGrpcSecurityMetadataSource remove(final ServiceDescriptor service) {
    requireNonNull(service, "service");
    for (final MethodDescriptor<?, ?> method : service.getMethods()) {
        this.accessMap.remove(method);
    }
    return this;
}
 
Example 7
Source File: AbstractMetricCollectingInterceptor.java    From grpc-spring-boot-starter with MIT License 2 votes vote down vote up
/**
 * Pre-registers the all methods provided by the given service. This will initialize all default counters and timers
 * for those methods.
 *
 * @param service The service to initialize the meters for.
 * @see #preregisterMethod(MethodDescriptor)
 */
public void preregisterService(final ServiceDescriptor service) {
    for (final MethodDescriptor<?, ?> method : service.getMethods()) {
        preregisterMethod(method);
    }
}
 
Example 8
Source File: AbstractMetricCollectingInterceptor.java    From grpc-spring-boot-starter with MIT License 2 votes vote down vote up
/**
 * Pre-registers the all methods provided by the given service. This will initialize all default counters and timers
 * for those methods.
 *
 * @param service The service to initialize the meters for.
 * @see #preregisterMethod(MethodDescriptor)
 */
public void preregisterService(final ServiceDescriptor service) {
    for (final MethodDescriptor<?, ?> method : service.getMethods()) {
        preregisterMethod(method);
    }
}