Add runnable examples, each smoke-tested against a stub - #21
Open
garretpremo wants to merge 1 commit into
Open
garretpremo wants to merge 1 commit into
garretpremo wants to merge 1 commit into
Conversation
Four examples under examples/, each its own Gradle project with a README, a run task, and a smoke test: - ticket-triage: keyed questions, models listing, and API errors; a port of the JavaScript SDK's demo. - typed-routing: Ask handles and an enum Choice, routed to a queue by an exhaustive switch. - async-batch: systemOneAsync fan-out with per-call options, a custom retry policy, and failures per item that don't sink the batch. - spring-boot: the starter behind POST /tickets/route, with TypeSafe failures mapped to 502 or 504 ProblemDetail responses. Each example takes its client through run(TypeSafeClient), so the tests point it at examples/support's in-process stub, and ./gradlew build checks every example with no API key. The README samples are output from real runs. The root build now configures only the two library modules, so nothing under examples/ is published. Refs #20
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #20. The issue was closed as not needed, but in-repo examples still help the repo: CI now breaks when an SDK change breaks a realistic program, newcomers have something they can run in one command, and the JS SDK has an
examples/directory too.What's here
Four examples under
examples/. Each is its own Gradle project with a short README, aruntask, and a smoke test.ticket-triagedemo.tstyped-routingAskhandles and an enumChoice, routed to a queue by an exhaustiveswitchasync-batchsystemOneAsyncfan-out with per-call options, a custom retry policy, and failures per itemspring-bootPOST /tickets/route, with TypeSafe failures mapped to 502/504ProblemDetailrun(TypeSafeClient), so its test points it atexamples/support's in-processStubTypeSafeServer. The Spring test setstypesafe.base-urlinstead../gradlew buildchecks all four with no API key and no secrets in CI.typesafe-sdkandtypesafe-sdk-spring-boot-starter, so nothing underexamples/is published. A dry run ofpublishToMavenCentraltouches only those two modules.Follow-ups found while writing these (not in this PR)
typesafe.api-key=${TYPESAFE_API_KEY}doesn't fail fast when the variable is unset. Boot binds the literal${TYPESAFE_API_KEY}as the key, so the first request gets a 401.${TYPESAFE_API_KEY:}, as the starter's Javadoc describes, is the form that works.exceptionallycallback receives aCompletionExceptionwrapping theTypeSafeException, not the exception itself. Onlyget()/join()hand back the unwrapped cause.ChoiceAnswer.probability()for the chosen label, and asystemOne(state, RequestOptions, Ask...)overload so per-call options don't force the builder form.