js-sdk
js-sdk copied to clipboard
Update DaprClient and DaprServer API for easier usage
Describe the proposal
The current DaprClient
API looks like this:
constructor(
daprHost?: string
, daprPort?: string
, communicationProtocol: CommunicationProtocolEnum = CommunicationProtocolEnum.HTTP
, options: DaprClientOptions = {},
)
Since typescript does not have support for named parameters, skipping one parameter and adding the next one will result in something like this on the consumer end:
var clientOptions = {logger: {level: LogLevel.Debug}}
const client = new DaprClient(
daprHost,
undefined, // default is process.env.DAPR_HTTP_PORT ?? 3500
undefined, // default is CommunicationProtocolEnum.HTTP
clientOptions);
The proposal is to move to a more friendlier DaprClient
API:
constructor(DaprClientOptions)
// ...
export type DaprClientOptions = {
daprHost?: string;
daprPort?: string;
communicationProtocol: CommunicationProtocolEnum;
isKeepAlive?: boolean;
logger?: LoggerOptions;
}
This will allow consumers to instantiate DaprClient
as follows:
const client = new DaprClient({
daprHost:daprHost,
logger:loggerOptions});
Similar exercise proposed for DaprServer
.
This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.
Hi @shubham1172 changes should be reflect in test cases to ?
Hi @shubham1172 changes should be reflect in test cases to ?
Yes, this proposal requires a broader discussion before any implementation, feel free to add them to this thread/join our community calls and talk about it.
Closing in favor of #442 and #444