Skip to content
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

Feature/subscription #13

Merged
merged 16 commits into from
Nov 6, 2023
Merged

Feature/subscription #13

merged 16 commits into from
Nov 6, 2023

Conversation

bplatz
Copy link
Contributor

@bplatz bplatz commented Oct 27, 2023

This is companion support for fluree/db subscriptions: fluree/db#605

When connecting to a fluree/server, the fluree/db library now launches a socket connection to keep up to date on ledger changes and maintains its internal state and a current copy of db's that are actively being used from the library.

Copy link
Contributor

@cap10morgan cap10morgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small logging things to consider / clean up. But very minor and looks good overall!


(defmethod client-message :on-bytes
[{:keys [http/sub-id payload offset len]}]
(log/info "websocket :on-bytes (no-op) message for sub-id: " sub-id))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log fns will insert the spaces between args for you (like println)


(defmethod client-message :on-error
[{:keys [http/sub-id error]}]
(log/warn "Websocket error for sub-id: " sub-id "with error: " (type error)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we log this at error level? Or are they so common that warn is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very common, just a network connection break. There is a list of error types, and I'd suspect the optimal solution will be to eventually case the error type, with some being log/debug all the way up to log/error. So log/warn is sort of an imperfect compromise. I think we'll have a better sense of what is best here once it is running.

"Sends a message to all subscriptions. Message sent as JSON stringified map
in the form: {action: commit, ledger: my/ledger, data: {...}}"
[{:keys [sub-atom] :as subscriptions} action ledger-alias data]
(log/warn "SEND MESSAGE TO ALL subscriptions: " subscriptions)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this logged at warn level?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a debugging message, I'll remove.

@bplatz
Copy link
Contributor Author

bplatz commented Nov 6, 2023

Updated to the latest fluree/db so it fixes the failing policy test, it also gets some commits that fixed the where syntax.

@bplatz bplatz merged commit 9079322 into main Nov 6, 2023
3 checks passed
@bplatz bplatz deleted the feature/subscription branch November 6, 2023 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants