本文整理了Java中reactor.core.publisher.Mono.checkpoint()
方法的一些代码示例,展示了Mono.checkpoint()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mono.checkpoint()
方法的具体详情如下:
包路径:reactor.core.publisher.Mono
类名称:Mono
方法名:checkpoint
[英]Activate assembly tracing for this particular Mono, in case of an error upstream of the checkpoint. Tracing incurs the cost of an exception stack trace creation.
It should be placed towards the end of the reactive chain, as errors triggered downstream of it cannot be observed and augmented with assembly trace.
[中]在检查点上游出现错误时,激活此特定Mono的程序集跟踪。跟踪会产生异常堆栈跟踪创建的成本。
应将其放置在反应链的末端,因为无法观察到在其下游触发的错误,并且无法通过装配跟踪来增加错误。
代码示例来源:origin: reactor/reactor-core
/**
* Activate assembly tracing for this particular {@link Mono}, in case of an error
* upstream of the checkpoint. Tracing incurs the cost of an exception stack trace
* creation.
* <p>
* It should be placed towards the end of the reactive chain, as errors
* triggered downstream of it cannot be observed and augmented with assembly trace.
*
* @return the assembly tracing {@link Mono}
*/
public final Mono<T> checkpoint() {
return checkpoint(null, true);
}
代码示例来源:origin: reactor/reactor-core
/**
* Activate assembly marker for this particular {@link Mono} by giving it a description that
* will be reflected in the assembly traceback in case of an error upstream of the
* checkpoint. Note that unlike {@link #checkpoint()}, this doesn't create a
* filled stack trace, avoiding the main cost of the operator.
* However, as a trade-off the description must be unique enough for the user to find
* out where this Mono was assembled. If you only want a generic description, and
* still rely on the stack trace to find the assembly site, use the
* {@link #checkpoint(String, boolean)} variant.
* <p>
* It should be placed towards the end of the reactive chain, as errors
* triggered downstream of it cannot be observed and augmented with assembly trace.
*
* @param description a unique enough description to include in the light assembly traceback.
* @return the assembly marked {@link Mono}
*/
public final Mono<T> checkpoint(String description) {
return checkpoint(Objects.requireNonNull(description), false);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void onAssemblyDescription() {
String monoOnAssemblyStr = Mono.just(1).checkpoint("onAssemblyDescription").toString();
System.out.println(Mono.just(1).checkpoint("onAssemblyDescription"));
assertTrue("Description not included: " + monoOnAssemblyStr, monoOnAssemblyStr.contains("checkpoint(\"onAssemblyDescription\")"));
}
代码示例来源:origin: reactor/reactor-core
@Test
public void monoCheckpointWithDescriptionIsLight() {
StringWriter sw = new StringWriter();
Mono<Object> tested = Mono.just(1)
.map(i -> null)
.filter(Objects::nonNull)
.checkpoint("foo")
.doOnError(t -> t.printStackTrace(new PrintWriter(sw)));
StepVerifier.create(tested)
.verifyError();
String debugStack = sw.toString();
assertThat(debugStack).contains("Assembly site of producer [reactor.core.publisher.MonoFilterFuseable] is identified by light checkpoint [foo].");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void monoCheckpointDescriptionAndForceStack() {
StringWriter sw = new StringWriter();
Mono<Object> tested = Mono.just(1)
.map(i -> null)
.filter(Objects::nonNull)
.checkpoint("foo", true)
.doOnError(t -> t.printStackTrace(new PrintWriter(sw)));
StepVerifier.create(tested)
.verifyError();
String debugStack = sw.toString();
assertThat(debugStack).contains("Assembly trace from producer [reactor.core.publisher.MonoFilterFuseable], described as [foo] :");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void monoCheckpointEmpty() {
StringWriter sw = new StringWriter();
Mono<Object> tested = Mono.just(1)
.map(i -> null)
.filter(Objects::nonNull)
.checkpoint()
.doOnError(t -> t.printStackTrace(new PrintWriter(sw)));
StepVerifier.create(tested)
.verifyError();
String debugStack = sw.toString();
assertThat(debugStack).contains("Assembly trace from producer [reactor.core.publisher.MonoFilterFuseable] :");
}
代码示例来源:origin: io.pivotal/pivotal-cloudfoundry-client-reactor
@Override
public Mono<CreateJobResponse> create(CreateJobRequest request) {
return post(request, CreateJobResponse.class, builder -> builder.pathSegment("jobs"))
.checkpoint();
}
代码示例来源:origin: io.pivotal/pivotal-cloudfoundry-client-reactor
@Override
public Mono<ListJobsResponse> list(ListJobsRequest request) {
return get(request, ListJobsResponse.class, builder -> builder.pathSegment("jobs"))
.checkpoint();
}
代码示例来源:origin: org.cloudfoundry/cloudfoundry-operations
@Override
public Mono<Stack> get(GetStackRequest request) {
return this.cloudFoundryClient
.flatMap(cloudFoundryClient -> getStack(cloudFoundryClient, request.getName()))
.map(this::toStack)
.transform(OperationsLogging.log("Get Stack"))
.checkpoint();
}
代码示例来源:origin: org.cloudfoundry/cloudfoundry-operations
@Override
public Mono<OrganizationQuota> getQuota(GetQuotaRequest request) {
return this.cloudFoundryClient
.flatMap(cloudFoundryClient -> getOrganizationQuota(cloudFoundryClient, request.getName()))
.map(DefaultOrganizationAdmin::toOrganizationQuota)
.transform(OperationsLogging.log("Get Organization Quota"))
.checkpoint();
}
代码示例来源:origin: io.pivotal/pivotal-cloudfoundry-client-reactor
@Override
public Mono<ScheduleJobResponse> schedule(ScheduleJobRequest request) {
return post(request, ScheduleJobResponse.class, builder -> builder.pathSegment("jobs", request.getJobId(), "schedules"))
.checkpoint();
}
代码示例来源:origin: org.cloudfoundry/cloudfoundry-operations
@Override
public Mono<Void> delete(DeleteOrganizationRequest request) {
return this.cloudFoundryClient
.flatMap(cloudFoundryClient -> Mono.zip(
Mono.just(cloudFoundryClient),
Mono.just(request.getCompletionTimeout()),
getOrganizationId(cloudFoundryClient, request.getName())
))
.flatMap(function(DefaultOrganizations::deleteOrganization))
.transform(OperationsLogging.log("Delete Organization"))
.checkpoint();
}
代码示例来源:origin: org.cloudfoundry/cloudfoundry-operations
@Override
public Mono<OrganizationQuota> updateQuota(UpdateQuotaRequest request) {
return this.cloudFoundryClient
.flatMap(cloudFoundryClient -> Mono.zip(
Mono.just(cloudFoundryClient),
getOrganizationQuota(cloudFoundryClient, request.getName())
))
.flatMap(function((cloudFoundryClient, exitingQuotaDefinition) -> updateOrganizationQuota(cloudFoundryClient, request, exitingQuotaDefinition)))
.map(DefaultOrganizationAdmin::toOrganizationQuota)
.transform(OperationsLogging.log("Update Organization Quota"))
.checkpoint();
}
代码示例来源:origin: org.cloudfoundry/cloudfoundry-operations
@Override
public Mono<SpaceQuota> get(GetSpaceQuotaRequest request) {
return Mono
.zip(this.cloudFoundryClient, this.organizationId)
.flatMap(function((cloudFoundryClient, organizationId) -> getSpaceQuotaDefinition(cloudFoundryClient, organizationId, request.getName())))
.map(DefaultSpaceAdmin::toSpaceQuota)
.transform(OperationsLogging.log("Get Space Quota"))
.checkpoint();
}
代码示例来源:origin: org.cloudfoundry/cloudfoundry-operations
@Override
public Mono<OrganizationDetail> get(OrganizationInfoRequest request) {
return this.cloudFoundryClient
.flatMap(cloudFoundryClient -> Mono.zip(
Mono.just(cloudFoundryClient),
getOrganization(cloudFoundryClient, request.getName())
))
.flatMap(function((cloudFoundryClient, organizationResource) -> getAuxiliaryContent(cloudFoundryClient, organizationResource)
.map(function((domains, organizationQuota, spacesQuotas, spaces) -> toOrganizationDetail(domains, organizationQuota, spacesQuotas, spaces, organizationResource, request)))))
.transform(OperationsLogging.log("Get Organization"))
.checkpoint();
}
代码示例来源:origin: org.cloudfoundry/cloudfoundry-operations
@Override
public Mono<Void> unshare(UnshareDomainRequest request) {
return this.cloudFoundryClient
.flatMap(cloudFoundryClient -> Mono.zip(
Mono.just(cloudFoundryClient),
getPrivateDomainId(cloudFoundryClient, request.getDomain()),
getOrganizationId(cloudFoundryClient, request.getOrganization())
))
.flatMap(function(DefaultDomains::requestRemoveOrganizationPrivateDomainRequest))
.transform(OperationsLogging.log("Unshare Domain"))
.checkpoint();
}
代码示例来源:origin: org.cloudfoundry/cloudfoundry-operations
@Override
public Mono<Void> restartInstance(RestartApplicationInstanceRequest request) {
return Mono
.zip(this.cloudFoundryClient, this.spaceId)
.flatMap(function((cloudFoundryClient, spaceId) -> Mono.zip(
Mono.just(cloudFoundryClient),
getApplicationId(cloudFoundryClient, request.getName(), spaceId)
)))
.flatMap(function((cloudFoundryClient, applicationId) -> requestTerminateApplicationInstance(cloudFoundryClient, applicationId, String.valueOf(request.getInstanceIndex()))))
.transform(OperationsLogging.log("Restart Application Instance"))
.checkpoint();
}
代码示例来源:origin: io.pivotal/pivotal-cloudfoundry-client-reactor
@Override
public Mono<ListJobScheduleHistoriesResponse> listScheduleHistories(ListJobScheduleHistoriesRequest request) {
return get(request, ListJobScheduleHistoriesResponse.class, builder -> builder.pathSegment("jobs", request.getJobId(), "schedules", request.getScheduleId(), "history"))
.checkpoint();
}
代码示例来源:origin: org.cloudfoundry/cloudfoundry-operations
@Override
public Mono<Boolean> sshAllowed(SpaceSshAllowedRequest request) {
return Mono
.zip(this.cloudFoundryClient, this.organizationId)
.flatMap(function((cloudFoundryClient, organizationId) -> getOrganizationSpace(cloudFoundryClient, organizationId, request.getName())))
.map(resource -> ResourceUtils.getEntity(resource).getAllowSsh())
.transform(OperationsLogging.log("Is Space SSH Allowed"))
.checkpoint();
}
代码示例来源:origin: org.cloudfoundry/cloudfoundry-operations
@Override
public Mono<Boolean> sshEnabled(ApplicationSshEnabledRequest request) {
return Mono
.zip(this.cloudFoundryClient, this.spaceId)
.flatMap(function((cloudFoundryClient, spaceId) -> getApplication(cloudFoundryClient, request.getName(), spaceId)))
.map(applicationResource -> ResourceUtils.getEntity(applicationResource).getEnableSsh())
.transform(OperationsLogging.log("Is Application SSH Enabled"))
.checkpoint();
}
内容来源于网络,如有侵权,请联系作者删除!