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

feat(statusd)_: websocket endpoint for getting events #5806

Merged
merged 4 commits into from
Sep 12, 2024

Conversation

igor-sirotin
Copy link
Collaborator

@igor-sirotin igor-sirotin commented Sep 6, 2024

Closes #5803

Description

This PR enables to get status-go events through a Websocket endpoint.

Screenshot 2024-09-08 at 21 17 37

Usage

  1. Run like this: statusd --server=localhost:12345.
  2. Connect with any websocket client to ws://localhost:12345

Response structure

  1. Response will be a TextMessage.
  2. The signal structure can be found here
    type Envelope struct {
    Type string `json:"type"`
    Event interface{} `json:"event"`
    }

    ... which is:
    {
        "type": "<event-type>",
        "event": {}, // event-specific properties here
    }

Events

Possible events are described in ./signals directory. Events are grouped by some logic:
image

For example, here's the events_community_reevaluation.go

It defines 1 signal: community.memberReevaluationStatus. It will be set as type of event in the signal.

const (
MemberReevaluationStatus = "community.memberReevaluationStatus"
)

With this event structure:

type CommunityMemberReevaluationSignal struct {
CommunityID string `json:"communityId"`
Status ReevaluationStatus `json:"status"`
}

@igor-sirotin igor-sirotin self-assigned this Sep 6, 2024
@status-im-auto
Copy link
Member

status-im-auto commented Sep 6, 2024

Jenkins Builds

Click to see older builds (10)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ f43b885 #1 2024-09-06 17:17:51 ~2 min tests-rpc 📄log
✖️ f43b885 #1 2024-09-06 17:18:03 ~2 min tests 📄log
✔️ f43b885 #1 2024-09-06 17:19:29 ~4 min linux 📦zip
✔️ f43b885 #1 2024-09-06 17:20:18 ~5 min ios 📦zip
✔️ f43b885 #1 2024-09-06 17:20:47 ~5 min android 📦aar
✔️ a830f8b #2 2024-09-06 22:40:01 ~1 min android 📦aar
✔️ a830f8b #2 2024-09-06 22:40:36 ~2 min linux 📦zip
✔️ a830f8b #2 2024-09-06 22:40:44 ~2 min tests-rpc 📄log
✔️ a830f8b #2 2024-09-06 22:43:38 ~5 min ios 📦zip
✔️ a830f8b #2 2024-09-06 23:09:48 ~31 min tests 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ e3c4edd #3 2024-09-12 12:21:17 ~1 min tests 📄log
✔️ e3c4edd #3 2024-09-12 12:21:57 ~2 min tests-rpc 📄log
✔️ e3c4edd #3 2024-09-12 12:23:19 ~3 min ios 📦zip
✔️ e3c4edd #3 2024-09-12 12:23:24 ~3 min linux 📦zip
✔️ e3c4edd #3 2024-09-12 12:24:06 ~4 min android 📦aar
✔️ 1d3c18a #4 2024-09-12 13:01:33 ~1 min android 📦aar
✔️ 1d3c18a #4 2024-09-12 13:02:05 ~2 min linux 📦zip
✔️ 1d3c18a #4 2024-09-12 13:02:15 ~2 min tests-rpc 📄log
✔️ 1d3c18a #4 2024-09-12 13:03:12 ~3 min ios 📦zip
✔️ 1d3c18a #4 2024-09-12 13:31:15 ~31 min tests 📄log

@igor-sirotin
Copy link
Collaborator Author

igor-sirotin commented Sep 8, 2024

I should probably rename SignalsServer to something more generic.

Thinking of this, something came up to my mind.
There's one more thing that statusd doesn't enable to test: mobile/status.go API.


This comment was converted to a ticket:


cc @antdanchenko @anastasiyaig @churik, would something like this help you with testing on status-go level?
We can have a chat and I'll show you more details if needed.

@anastasiyaig
Copy link
Contributor

@igor-sirotin i love the fact i can use web sockets, thats amazing:) i would appreciate a call with you to go through all this together 🙏
i think @glitchminer is also interested

Copy link
Contributor

@osmaczko osmaczko left a comment

Choose a reason for hiding this comment

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

Nice and clean!

cmd/statusd/signals_server.go Outdated Show resolved Hide resolved
cmd/statusd/signals_server_test.go Outdated Show resolved Hide resolved
cmd/statusd/main.go Outdated Show resolved Hide resolved
@osmaczko
Copy link
Contributor

Thinking of this, something came up to my mind.
There's one more thing that statusd doesn't enable to test: mobile/status.go API.

Good point.

Proposal

  1. Reuse this SignalsServer to enable functional testing of mobile/status.go API.
    Add api/restore-account-and-login kind of endpoints.
  2. Remove from statusd all logic of creating/restoring accounts.
    Just set up the SignalsServer to provide a full status-go API with HTTP.
  3. Remove CLI arguments like --seed-phrase, --password, --config, etc.
    Instead, use RestoreAccountAndLogin and pass desired configuration with it.

Maybe instead having two separate servers and many endpoints for mobile/status.go API we could have one server which will both handle mobile/status.go calls and proxy to RPC server spawn by GethBackend.

I like the idea in general, but I would be cautious with clients of statusd. I'm not sure if it would be feasible to shift the responsibility of account creation, restoration, etc., for all clients. For instance, see: Mailserver README and Bootnode README, although I'm not certain whether either of these is still relevant.

@igor-sirotin igor-sirotin merged commit 9038c66 into develop Sep 12, 2024
11 checks passed
@igor-sirotin igor-sirotin deleted the feat/http-signals-5803 branch September 12, 2024 13:35
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.

Enable subscribing to signals/events with an HTTP endpoint in statusd
5 participants