Client: Refactor channel creation

Summary

New API for channel and channel credentials creation

  • Unified semantics
  • Complete JavaDoc documentation

Changes

Reworked class ChannelBuilder

  • Can be used to create ManagedChannelBuilders
  • Only for situations where custom channel configuration is required (e.g. setting interceptors or executors)
  • Javadoc suggests to use ChannelFactory instead if no further channel configuration is required
ManagedChannelBuilder<?> channelBuilder = ChannelBuilder.withTLSEncryption(@NonNull String host, int port);
ManagedChannelBuilder<?> channelBuilder = ChannelBuilder.withTLSEncryption(@NonNull String host, int port, @NonNull X509Certificate customCertificateAuthority);
ManagedChannelBuilder<?> channelBuilder = ChannelBuilder.withTLSEncryption(@NonNull String host, int port, @NonNull String customCertificateAuthority);
ManagedChannelBuilder<?> channelBuilder = ChannelBuilder.withTLSEncryption(@NonNull String host, int port, @NonNull InputStream customCertificateAuthority);

// deprecated
ManagedChannelBuilder<?> channelBuilder = ChannelBuilder.withoutEncryption(@NonNull String host, int port);

Reworked class ChannelFactory

  • Same as ChannelBuilder.xxx(...).build()
  • Provides complete abstraction from the underlying gRPC channel creation API
ManagedChannel channel = ChannelFactory.getTLSEncryptedChannel(@NonNull String host, int port);
ManagedChannel channel = ChannelFactory.getTLSEncryptedChannel(@NonNull String host, int port, @NonNull X509Certificate customCertificateAuthority);
ManagedChannel channel = ChannelFactory.getTLSEncryptedChannel(@NonNull String host, int port, @NonNull String customCertificateAuthority);
ManagedChannel channel = ChannelFactory.getTLSEncryptedChannel(@NonNull String host, int port, @NonNull InputStream customCertificateAuthority);

// deprecated
ManagedChannel channel = ChannelFactory.getUnencryptedChannel(@NonNull String host, int port);

Moved server-specific methods from ChannelCredentialsFactory

  • Server credential handling does not belong to core.sila.clients
  • Methods were used only in one place (SiLAServer). Moved them there.

Removed class ChannelCredentialsFactory

All its functionality is contained in ChannelFactory.

Removed class ChannelUtils

Its content was only used in one place (TextBase). Moved it there.

Merge request reports

Loading