Comments (12)
Glad I could help. We haven't started yet on Go server code generation. Out of curiosity and to help us plan, what kinds of environments are you deploying to? Traditional servers like EC2, Fargate containers, Lambda and API Gateway?
from smithy-go.
It looks like your smithy-build.json
isn't quite right for starters, you can see an example here. I'm not sure what your project structure looks like, but the Smithy docs have an example here using the Smithy Gradle plugin, plus some other examples here.
version 15 to build Smithy itself since v8 wouldn't work
That's odd - what error do you get trying to build Smithy on JDK 8? That's the version we build with, and we've got automated tests running that and a few other versions across multiple operating systems. In any event, Smithy is published to Maven so you don't need to build it yourself.
The documentation is very sparse
What docs in particular are lacking? The smithy-go and aws-sdk-go-v2 code generators aren't GA yet, but when they are they'll certainly be documented. If the problems are with core Smithy itself though, we'd appreciate feedback over on the main repo so we can get around to improving it.
from smithy-go.
@JordonPhillips thanks for prompt help!
It looks like your
smithy-build.json
isn't quite right for starters, you can see an example here. I'm not sure what your project structure looks like, but the Smithy docs have an example here using the Smithy Gradle plugin, plus some other examples here.
Thanks for the example, I wasn't sure what to fill in for the Go plugin config :)
version 15 to build Smithy itself since v8 wouldn't work
That's odd - what error do you get trying to build Smithy on JDK 8? That's the version we build with, and we've got automated tests running that and a few other versions across multiple operating systems. In any event, Smithy is published to Maven so you don't need to build it yourself.
I'm just building Smithy myself in order to hack it and understand how it works, so I won't have to use it via Gradle (I'd rather use it directly). It fails like this:
$ ./gradlew :smithy-cli:runtime
Starting a Gradle Daemon (subsequent builds will be faster)
> Configure project :
Smithy version: '1.7.0'
> Task :smithy-cli:jre FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':smithy-cli:jre'.
> Directory not found: /usr/local/opt/openjdk@8/libexec/openjdk.jdk/Contents/Home/jmods
The documentation is very sparse
What docs in particular are lacking? The smithy-go and aws-sdk-go-v2 code generators aren't GA yet, but when they are they'll certainly be documented. If the problems are with core Smithy itself though, we'd appreciate feedback over on the main repo so we can get around to improving it.
I'd basically like to understand how to use Smithy without Gradle, and especially how to use it with a plugin such as Smithy Go. That's what I can think of right now, there's probably a lot more. I can tell you more, once I'm able to emit Go code.
from smithy-go.
@JordonPhillips I tried fixing smithy-build.json using the example you provided, but an exception is thrown in the same manner as before. Are you sure it's connected to the contents of smithy-build.json? See my draft PR for what I've done so far.
from smithy-go.
Directory not found: /usr/local/opt/openjdk@8/libexec/openjdk.jdk/Contents/Home/jmods
This looks like a generic java error where it can't find your jdk. Though the jmods thing is curious since that's Java 9+
Are you sure it's connected to the contents of smithy-build.json?
No, the specific error you hit is gonna be due to something else, but you would have hit another error later with a misconfigured smithy-build definition.
I'd basically like to understand how to use Smithy without Gradle, and especially how to use it with a plugin such as Smithy Go.
Ah, I see. I think the problem is related - since you're not using gradle the classpath isn't getting built up for you. You might need a fat jar made of smithy-cli + smithy-go if you want to avoid gradle. Or otherwise make sure that everything is on the classpath in some other way.
As far as the commands sent to smithy-cli, running gradle in debug mode will show you what commands are sent.
from smithy-go.
@JordonPhillips the fat jar solution sounds OK to me. How would I go about it? I'm really pretty clueless when it comes to Java.
from smithy-go.
Directory not found: /usr/local/opt/openjdk@8/libexec/openjdk.jdk/Contents/Home/jmods
This looks like a generic java error where it can't find your jdk. Though the jmods thing is curious since that's Java 9+
@JordonPhillips the JDK is there at least, but I could confirm that the jmods directory is missing in 8.
from smithy-go.
Yeah I have no idea why it's looking for jmods - smithy certainly isn't using modules. That's probably a more generic gradle question, since it does kinda look like it's confusing two java versions.
As far as the fat jar, there's a number of ways to go about it. I know there's a plugin called shadow that'll make one, for instance.
from smithy-go.
Building the CLI requires Java 9 or higher because it uses jlink. This explains the jmods errors and the like.
There are some things to consider with using the Smithy CLI instead of Gradle:
- The CLI generates platform specific builds. You really can't embed the output in a git repo, so I'm not sure how you'd use it this way. I think for this to work, we'd need to distribute the Smithy CLI to package managers. We also provide some Docker configuration that you could potentially use to invoke the CLI. However, that still leads to the next issue.
- The CLI doesn't handle dependencies. You'd need to manually download the JARs you need for Smithy, the Go generators, and any other trait packages, and pass them into the CLI as positional arguments.
When using Smithy tooling with other tools, you can usually invoke Smithy from wrapper scripts that kick off Gradle and do work. So for example, if you use Make, then you can add a Make task to run Gradle instead of requiring your users to invoke Gradle directly. We take this approach in AWS SDKs for example.
from smithy-go.
Building the CLI requires Java 9 or higher because it uses jlink. This explains the jmods errors and the like.
Aha thanks for that info, so I can use Java 15, i.e. my default version?
There are some things to consider with using the Smithy CLI instead of Gradle:
- The CLI generates platform specific builds. You really can't embed the output in a git repo, so I'm not sure how you'd use it this way. I think for this to work, we'd need to distribute the Smithy CLI to package managers. We also provide some Docker configuration that you could potentially use to invoke the CLI. However, that still leads to the next issue.
- The CLI doesn't handle dependencies. You'd need to manually download the JARs you need for Smithy, the Go generators, and any other trait packages, and pass them into the CLI as positional arguments.
Interesting. This goes way beyond my Java/JVM knowledge, but it does sound as if it would be easier for me to just use Gradle.
When using Smithy tooling with other tools, you can usually invoke Smithy from wrapper scripts that kick off Gradle and do work. So for example, if you use Make, then you can add a Make task to run Gradle instead of requiring your users to invoke Gradle directly. We take this approach in AWS SDKs for example.
Thanks for the info. Basically it sounds as if I'll have a much easier time just using Gradle. I didn't realize it would be so much more difficult to use the Smithy CLI directly! I'm going to try with Gradle and see if I can get it working.
from smithy-go.
Closing this for now, since I've resolved the fundamentals. In my Grafana PR I'm able to generate client Go code and OpenAPI. Can someone tell me though if generating of server Go code is unimplemented as of yet? Can't see that it's happening.
from smithy-go.
@mtdowling Grafana is a traditional server product, that can be deployed anywhere (although not to serverless obviously).
Thanks for confirming regarding Go server code, good to know. At this stage I've just made a PoC regarding the applicability of Smithy for future iterations on Grafana HTTP API BTW. It's looking very promising!
from smithy-go.
Related Issues (20)
- codegen/runtime: Interceptors
- runtime: sigv4 signer
- runtime: sigv4a signer
- refactor: replace middleware with explicit operation phases
- codegen: remove "V2" suffix from endpoint resolution codegen
- codegen/runtime: @httpChecksum
- publish to maven
- runtime: refactor httpBearerAuth
- codegen: `RuntimeClientPlugin` not having access to a `SymbolProvider` HOT 1
- docs: revamp README and usage guide HOT 1
- Middleware, Transport (and maybe others) broken since aws-sdk-go-v2 release-2023-11-15 HOT 1
- codegen/runtime: operation checksums
- protocol: smithy.protocols#rpcv2Cbor HOT 1
- codegen/runtime: event streams
- Explore ways to reduce size of generated output HOT 3
- codegen: refactor waiters/paginators to be not integrations
- codegen: use DirectedCodegen in client codegen
- rename go-codegen plugin to go-client-codegen
- test: migrate auth scheme resolution tests to standalone, generated module
- enhancement: support range iterators in paginators
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smithy-go.