Skip to content

how is PartialServiceConfiguration class being used? #32

Open

Description

@qinfchen

ClientConfiguration can be created using ServiceConfiguration and there is no easy way to convert PartialServiceConfiguration to ServiceConfiguration or vice versa even though they are pretty much identical except for the absence of security. I would like know more about how we intend to use the PartialServiceConfiguration class

EDIT: saw ServiceConfigurationFactor.propagateDefaults and answered my question above.

Activity

  1. qinfchen commented on Aug 16, 2017

    @qinfchen
    ContributorAuthor

    Can we make ServiceConfigurationFactory.propagateDefaults public?

  2. uschi2000 commented on Aug 16, 2017

    @uschi2000
    Contributor

    What's the use-case for this?

  3. qinfchen commented on Aug 16, 2017

    @qinfchen
    ContributorAuthor

    Having a PartialServiceConfiguration declare outside the service discovery block like multipass'

    auth:
      legacyModeEnabled: false
      multipass:
        security:
          trustStorePath: var/security/trustStore.jks
        uris:
        - https://multipass.palantir.dev:8643/multipass/api
    

    or slate's postgate data source config

    - dataSourcePoolCacheTimeout: 1m
      databaseName: palantir
      driver: org.postgresql.ds.PGSimpleDataSource
      maximumDataSourcePoolSize: 30
      name: Foundry
      portNumber: 5432
      postgate:
        uris: https://spp.palantir.dev:6473/postgate/api/
      serverName: postgres.palantir.dev
      type: foundry
    

    It'd be great if we can specify service configuration outside of service discovery without requiring ssl block. Unless we are encouraging teams to only take service configuration from service discovery?

  4. uschi2000 commented on Aug 17, 2017

    @uschi2000
    Contributor

    In order to use propagateDefaults, you'd need a handle on a ServiceConfigBlock; if you have one of those, why not use ServiceConfigurationFactory#get ?

  5. qinfchen commented on Aug 17, 2017

    @qinfchen
    ContributorAuthor

    ServiceConfigBlock may not have the corresponding service config block for the PartialServiceConfiguration. I wonder if we should expose a convenient method of converting PartialServiceConfiguration to a ServiceConfiguration by filling in the defaults that are not present, which is what propagateDefaults does mostly

  6. uschi2000 commented on Aug 17, 2017

    @uschi2000
    Contributor

    Such a method exists: build a custom ServiceConfigBlock and then call get().

  7. meditativeape commented on Aug 24, 2017

    @meditativeape
    Contributor

    ServiceConfigurationFactory#get only works for services defined in the ServicesConfigBlock. In some places, we define partial service configurations outside of the service discovery block, for example workers, and event consumers. The defaults in ServicesConfigBlock should get propagated to those as well, but currently there's no good way of doing that.

  8. ash211 commented on Oct 3, 2017

    @ash211
    Contributor

    I had to do this also, workaround is to build a ServicesConfigBlock with a named service and then retrieve the same service back.

        protected static final PartialServiceConfiguration STATS_CONFIG =
                PartialServiceConfiguration.of(Lists.newArrayList(STATS_URI + "api/"), Optional.of(SSL_CONFIGURATION));
    
    <snip>
    
            // TODO(aash): is going through a ServiceConfigurationFactory the best way to convert
            // PartialServiceConfiguration -> ClientConfiguration ?
            stats = JaxRsClient.create(FoundryStatsService.class, USER_AGENT, ClientConfigurations.of(
                    ServiceConfigurationFactory.of(
                            ServicesConfigBlock.builder().putServices("foundry-stats", STATS_CONFIG).build()).get(
                            "foundry-stats")));
    

    @uschi2000 is this what you intend?

  9. uschi2000 commented on Oct 4, 2017

    @uschi2000
    Contributor

    We can add a static method ServiceConfigurationFactory that turns a partial config into a full one, or throws if not all required fields are set.

  10. qinfchen commented on Oct 4, 2017

    @qinfchen
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions