5 commented on code in PR #47:
URL: https://github.com/apache/cassandra-sidecar/pull/47#discussion_r1224654736


##########
src/main/java/org/apache/cassandra/sidecar/MainModule.java:
##########
@@ -311,4 +320,28 @@ public ChecksumVerifier checksumVerifier(Vertx vertx)
     {
         return new MD5ChecksumVerifier(vertx.fileSystem());
     }
+
+    @Provides
+    @Singleton
+    @Named("SidecarVersion")
+    public String sidecarVersion()
+    {
+        String resource = "/sidecar.version";
+        try (InputStream input = 
NodeSettings.class.getResourceAsStream(resource);
+             ByteArrayOutputStream output = new ByteArrayOutputStream())
+        {
+            byte[] buffer = new byte[32];
+            int length;
+            while ((length = input.read(buffer)) >= 0)
+            {
+                output.write(buffer, 0, length);
+            }
+            return output.toString(StandardCharsets.UTF_8.name());
+        }
+        catch (Exception exception)
+        {
+            LOGGER.error("Failed to retrieve Sidecar version from resource 
{}", resource, exception);

Review Comment:
   To explain my motivation: if we don't have a resource with version build 
into Sidecar, then something went wrong with the artifact build process, but it 
doesn't prevent us from starting up and serving requests, so just log an error, 
and return "`unknown`", which only appears on the usage dashboard.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to