-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
393-js-publish-async and utils / tests / misc #398
Conversation
.name(streamName) | ||
.storageType(storageType) | ||
.subjects(subject) | ||
.build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convention is to put the dot at the beginning. also when concatenating strings with + it goes at the beginning, or using && for multi line if. It makes it easier to comment out a line too.
} | ||
return ea; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that this was repeated so I refactored it.
CompletableFuture<PublishAck> publishAsync(String subject, byte[] body); | ||
CompletableFuture<PublishAck> publishAsync(String subject, byte[] body, PublishOptions options); | ||
CompletableFuture<PublishAck> publishAsync(Message message); | ||
CompletableFuture<PublishAck> publishAsync(Message message, PublishOptions options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This for #393
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just needs comments.
@@ -438,7 +432,7 @@ static DecodedSeed decodeSeed(char[] seed) { | |||
private static NKey createPair(Type type, SecureRandom random) | |||
throws IOException, NoSuchProviderException, NoSuchAlgorithmException { | |||
if (random == null) { | |||
random = new SecureRandom(); | |||
random = SRAND; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shared secure random
private static final String QCOLONQ = "\": \""; | ||
private static final String QCOLON = "\": "; | ||
private static final String QCOLONQ = "\":\""; | ||
private static final String QCOLON = "\":"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space is not required. Not need to send extra bytes
@@ -65,22 +66,22 @@ | |||
AccountLimitImpl(String json) { | |||
Matcher m = LIMITS_MEMORY_RE.matcher(json); | |||
if (m.find()) { | |||
this.memory = Integer.parseInt(m.group(1)); | |||
this.memory = Long.parseLong(m.group(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the long parser since the variables are long.
} | ||
}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This for #393
import java.security.SecureRandom; | ||
import java.util.Random; | ||
|
||
public abstract class RandomUtils { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Utils provides shared random. Both Random and Secure random are thread-safe.
} | ||
|
||
private static StreamInfo createMemoryStream(JetStream js, String streamName, String[] subjects) | ||
private static StreamInfo createMemoryStream(JetStream js, String streamName, String... subjects) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This signature will accept one (zero actually) or more strings, so we don't need 2 methods
Assertions.fail("Exception: " + ex.getMessage()); | ||
} finally { | ||
nc.close(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If an exception is throw the test will fail naturally, so no need to check for it.
- Finally to close the connection is not required since Connection implements AutoCloseable and the object is created via the try, the close happens automatically.
// check success | ||
opts.setExpectedStream("foo-stream"); | ||
opts.setExpectedLastSeqence(PublishOptions.unsetLastSequence); | ||
js.publish("foo", null, opts); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this now passes since the server is fixed.
catch (IllegalStateException ise) { | ||
System.out.println(ise.getMessage()); | ||
} | ||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intend to leave this in?
|
||
package io.nats.client; | ||
|
||
// TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need class comment...
MAINTAINERS.md
Outdated
@@ -8,3 +8,4 @@ Maintainership is on a per project basis. | |||
- Colin Sullivan <colin@nats.io> [@ColinSullivan1](https://github.com/ColinSullivan1) | |||
- Derek Collison <derek@nats.io> [@derekcollison](https://github.com/derekcollison) | |||
- Ivan Kozlovic <ivan@nats.io> [@kozlovic](https://github.com/kozlovic) | |||
- Scott Fauerbach <scott@nats.io> [@scottf](https://github.com/scottf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we can't do this right now. We need a formal vote to add you as a Maintainer per NATS Governance. We'll certainly revisit this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok sorry, will remove
action("Make And Use Subscription"); | ||
SubscribeOptions so = SubscribeOptions.builder() | ||
.pullDirect(STREAM1, "GQJ3IvWo", 10) | ||
// .configuration(STREAM1, cc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intended to be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example that I have not finished
} | ||
|
||
private static void action(String label) { | ||
System.out.println("================================================================================"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like an issue with spacing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just debug stuff using to show what's going on
*/ | ||
PublishAck publish(Message message, PublishOptions options) throws IOException, JetStreamApiException; | ||
|
||
CompletableFuture<PublishAck> publishAsync(String subject, byte[] body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs comments...
|
||
package io.nats.client.impl; | ||
|
||
public class JetStreamApiException extends Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class and methods will need doc... may not make it through travis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will comment for next PR
|
||
private Message makeRequest(NatsMessage natsMessage, Duration timeout) throws IOException { | ||
try { | ||
return responseRequired(conn.request(natsMessage, timeout)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this'll miss the prefix...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of work here! LGTM so far - a few comments on docs, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per offline discussion, after comments are added LGTM. Feel free to merge..
Misc changes and attempt at #393