Skip to content

Conversation

@superdevofficial
Copy link

Allow developers to choose which service will be published on cote, in order to reduce bandwith usage, or for security purpose.

usage

Add distributeIgnore = true in service to prevent feathers-distributed to publish the service.
** Each microservice has to publish at least one service, otherwise it will be not discovered **

@claustres
Copy link
Member

Thanks for this work, it seems to be a valuable addition ! Since options is not really a standardized extension to a FeatherJS service I wonder if this information will not be more easy to customize for people, without the need to change their code, in the distributed module configuration. What I propose is the following: by default services are exposed if no option is provided (for backward compatibility), otherwise you can provide a list of services to be distributed or a function for more dynamic behaviors.

Here is a code sample:

app.configure(
  distribution({
    // Static list
    services: ['Service1', 'Service2']
    // OR dynamic list
    services: (service) => MyDynamicList.includes(service.path)
  })
)

Ideally by default services should probably be not exposed for security concerns but this will however be a big breaking change.

As a reference and for changelog generation I open this issue to explain the problem solved and refer to that PR so that if people are looking for information they will easily find it.

Let me know what you think.

@claustres
Copy link
Member

Just published a version with the proposed solution, you should have the same behavior as you have in your PR like this:

app.configure(
  distribution({
    services: (serviceDescriptor) => {
      const service = app.services[serviceDescriptor.path]
      return !service.options.distributeIgnore
    }
  })
)

Let me know if it's fine and close this PR. Thanks for making this idea a reality.

@claustres
Copy link
Member

Closing now in favor of #22.

@claustres claustres closed this Jun 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants