From 3570af6d1575234789fbd52f010c15556aa4c986 Mon Sep 17 00:00:00 2001 From: Laszlo Fogas Date: Mon, 23 Oct 2023 17:26:14 +0200 Subject: [PATCH] Streaming envelope --- pkg/controllers/gitrepositoryController.go | 5 ++++- pkg/streaming/types.go | 10 ++++++++++ web/src/redux.js | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 pkg/streaming/types.go diff --git a/pkg/controllers/gitrepositoryController.go b/pkg/controllers/gitrepositoryController.go index 43bc84b..1f726fd 100644 --- a/pkg/controllers/gitrepositoryController.go +++ b/pkg/controllers/gitrepositoryController.go @@ -37,7 +37,10 @@ func GitRepositoryController( if err != nil { panic(err.Error()) } - fluxStateBytes, err := json.Marshal(fluxState) + fluxStateBytes, err := json.Marshal(streaming.Envelope{ + Type: streaming.FLUX_STATE_RECEIVED, + Payload: fluxState, + }) if err != nil { panic(err.Error()) } diff --git a/pkg/streaming/types.go b/pkg/streaming/types.go new file mode 100644 index 0000000..d28de0f --- /dev/null +++ b/pkg/streaming/types.go @@ -0,0 +1,10 @@ +package streaming + +const ( + FLUX_STATE_RECEIVED string = "FLUX_STATE_RECEIVED" +) + +type Envelope struct { + Type string `json:"type"` + Payload interface{} `json:"payload"` +} diff --git a/web/src/redux.js b/web/src/redux.js index f0bc930..d9d376f 100644 --- a/web/src/redux.js +++ b/web/src/redux.js @@ -2,7 +2,7 @@ export const initialState = { fluxState: {} } -export const ACTION_FLUX_STATE_RECEIVED = 'ACTION_FLUX_STATE_RECEIVED'; +export const ACTION_FLUX_STATE_RECEIVED = 'FLUX_STATE_RECEIVED'; export function rootReducer(state = initialState, action) { switch (action.type) {