-
Notifications
You must be signed in to change notification settings - Fork 212
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
Continuation of event support PR #490
Conversation
@terev Thanks so much for addressing the comments on the PR and sorry for the late reply. This looks good to me. Thanks again! |
Hey @terev, I'm sorry I neglected your PR. I'll find some time this week to look into it. |
no worries! |
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.
(when you rebase, can you make sure that events to any new endpoints, such as compose?) |
Any updates on this one? That would be awesome to have this branch being part of an official release 🙏 |
@mlhamel sorry i've neglected this for too long. i'll get this pr ready for review sometime this week |
Co-authored-by: francisco souza <108725+fsouza@users.noreply.github.com>
@fsouza I've completed the following:
|
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.
Nice, did a quick review and everything looks ok! I'll give it another review later today and likely merge and release it before EOY 😁
Happy to see this coming through :D
@terev btw, can you fix the lint failure? (just need |
Looks like this allows fakegcs to publish notifications to PubSub ? How can this be used, or configured ? Is there some documentation somewhere. Sorry I did my search but couldn't find anything. |
I just realized it is possibly achievable by adding the PUBSUB_EMULATOR_HOST env variable to the fage-gcs-server. I am going to try it right now and share if it worked. |
@Ortega-Dan Yeah that's the way to get the server to call an emulated pubsub server. But you'll also need to set a few pubsub config options. You can find the flags added by this mr here https://github.com/fsouza/fake-gcs-server/pull/490/files#diff-54c7c1af5fa8d5db4dc49f0e8e80e93ba2b1183ba4d5c9e2e5729e6deae6a3cdR66-R69 . |
Thank you very much @terev I was able to successfully get the two emulators to communicate with each other with:
then and and I have even made sure I created the project and topic first in the PubSub emulator, and tested the PubSub emulator independently ... but when I create a file with: WriteChannel channel = storage
.writer(BlobInfo.newBuilder(bucketName, "some_file2.txt").build());
channel.write(ByteBuffer.wrap("line3\n".getBytes()));
channel.write(ByteBuffer.wrap("line4\n".getBytes()));
channel.close(); I am able to confirm the file gets created but the notification never gets there. I am also able to confirm that the PubSub server is definitely reachable by the fakegcs because the PubSub at least detects the connection but only when the fakegcs starts.
but when the file is created there is no PubSub message delivered. Could there be something else missing ? |
@Ortega-Dan The pubsub emulator takes a --project flag which may be what you're missing. It should match the project id you pass to gcs emulator. Additionally I don't think the topic won't be automatically created. So you'll need to call the emulator's api to create it https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics/create . |
Thanks @terev . I included the project to the pubsub emulator like: (Just noting: After identifying the real issue shown in the previous message, It was shown that the --project flag for the pubsub emulator was not the real problem, even when it is recommended) |
While I was writing the previous message, I added some additional code that I had removed before from the cloud storage client, that was just a read instruction of the previously uploaded bucket. WriteChannel channel = storage
.writer(BlobInfo.newBuilder(bucketName, "veryNewFile.txt").build());
channel.write(ByteBuffer.wrap("line3\n".getBytes()));
channel.write(ByteBuffer.wrap("line4\n".getBytes()));
channel.close();
// ... BY ADDING THE FOLLOWING LINES AGAIN ...
Blob someFile2 = storage.get(bucketName, "veryNewFile.txt");
String fileContent = new String(someFile2.getContent()); And when that happened, and only after that additional instruction (even when the previous instruction already closed the file by closing the writechannel), I saw the following error:
Which was solved then by starting fakegcs with the notification flags as:
instead of:
I was providing the full topic name, because that is what other tools like PubSub have required. From this we could: improve the help flag description, to note that only the final portion of the topic name is required for that flag, and possibly error out from the beginning if a full topic name is provided. |
@Ortega-Dan Ah I see. Glad you got it working! It seems the error message didn't get flushed right away as the writer is line buffered and that specific write doesn't include a newline. Those are great change suggestions. |
This pr is a continuation of PR #370 created by @isaldana . I hope its okay that I picked up this work. This would be a really great feature to have available. If this pr is accepted I want to make sure the work is attributed to @isaldana. I was sure to rebase that work to retain their commits.
I've addressed the comment left on his pr about moving event options to a separate struct. I've also made a few fixes including:
@isaldana please feel free to veto this pr if you prefer i dont submit it on your behalf