gpt4 book ai didi

Java AWS Lambda - Avoid passing context too far down tree of calls(Java AWS Lambda-避免将上下文传递到调用树下太远的位置)

转载 作者:bug小助手 更新时间:2023-10-28 10:10:54 26 4
gpt4 key购买 nike



I used Dagger to inject dependencies on a Java Lambda:

我使用Dagger在Java Lambda上注入依赖项:


public class LambdaEntryPointHandler implements RequestHandler<SQSEvent, SQSBatchResponse> {
private final Handler handler;

public LambdaEntryPointHandler() {
ServiceComponent component = DaggerServiceComponent.create();
handler = component.getRequestHandler();
}

@Override
public SQSBatchResponse handleRequest(final SQSEvent sqsEvent, final Context context) {
return handler.handleRequest(sqsEvent, context);
}
}

I need to access the awsRequestId of the context in a call far down the chain of calls, it's really tedious to pass the context object as a parameter to all the caller functions. I was wondering if using Dagger I could inject the context as a dependency to that class that uses it, instead of passing the parameter.

我需要在调用链下游的调用中访问上下文的awsRequestID,将上下文对象作为参数传递给所有调用者函数真的很繁琐。我想知道是否可以使用Dagger将上下文作为依赖项注入使用它的类,而不是传递参数。


I'm open to other suggestions, is there a global store available in this case? (Something like redux in react, to avoid passing props down the component tree)

我对其他建议持开放态度,这种情况下有没有全球商店?(类似Reaction中的redux,以避免在组件树中传递道具)


I saw this answer, but I don't use Spring.

我看到了这个答案,但我没有使用Spring。


更多回答
优秀答案推荐
更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com