+
Skip to content

Conversation

WashingtonKK
Copy link
Contributor

@WashingtonKK WashingtonKK commented Sep 9, 2024

What type of PR is this?

This is an enhancement that improves the status of events sent from agent and manager.

What does this do?

This enhances the events sent from agent and manager to make them more user friendly.

Which issue(s) does this PR fix/relate to?

Have you included tests for your changes?

Not needed.

Did you document any new/modified feature?

No

Notes

To be merged along with: https://github.com/ultravioletrs/prism/pull/478

@WashingtonKK WashingtonKK changed the title enhance timeline NOISSUE : Enhance Event Status Sep 9, 2024
agent/service.go Outdated
svc.sm.StateFunctions[resultsReady] = svc.publishEvent("in-progress", json.RawMessage{})
svc.sm.StateFunctions[complete] = svc.publishEvent("in-progress", json.RawMessage{})
svc.sm.StateFunctions[results] = svc.publishEvent("ready", json.RawMessage{})
svc.sm.StateFunctions[complete] = svc.publishEvent("complete", json.RawMessage{})
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use constants here and any other appropriate place.

agent/state.go Outdated
receivingData
running
resultsReady
results
Copy link
Contributor

Choose a reason for hiding this comment

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

use a verb

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's results so that the full event with status would be: results ready. Rather than resultsReady ready

Copy link
Contributor

Choose a reason for hiding this comment

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

state results is not really self explanatory here, a better term is required

agent/service.go Outdated
Comment on lines 94 to 101
svc.sm.StateFunctions[idle] = svc.publishEvent("idle", json.RawMessage{})
svc.sm.StateFunctions[receivingManifest] = svc.publishEvent(progress, json.RawMessage{})
svc.sm.StateFunctions[receivingAlgorithm] = svc.publishEvent(progress, json.RawMessage{})
svc.sm.StateFunctions[receivingData] = svc.publishEvent(progress, json.RawMessage{})
svc.sm.StateFunctions[results] = svc.publishEvent("ready", json.RawMessage{})
svc.sm.StateFunctions[complete] = svc.publishEvent("complete", json.RawMessage{})
svc.sm.StateFunctions[running] = svc.runComputation
svc.sm.StateFunctions[failed] = svc.publishEvent("failed", json.RawMessage{})
Copy link
Contributor

Choose a reason for hiding this comment

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

make status a typed constant for consistency

agent/state.go Outdated
ReceivingAlgorithm
ReceivingData
Running
ResultFetch
Copy link
Contributor

Choose a reason for hiding this comment

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

ConsumingResults is better here, with status started, in progress and complete

Comment on lines +27 to +34
type Status uint8

const (
IdleState Status = iota
InProgress
Ready
Completed
Terminated
Copy link
Contributor

Choose a reason for hiding this comment

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

manager also has status and will have a general pattern, started, in progress, complete and failed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using these statuses for manager.

Copy link
Contributor

Choose a reason for hiding this comment

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

events are also published from manager on other files like agent events, and vm package as well as logging

Copy link
Contributor

Choose a reason for hiding this comment

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

see also agent logging and algorithm package

Copy link
Contributor Author

@WashingtonKK WashingtonKK Sep 13, 2024

Choose a reason for hiding this comment

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

All events use the states and statuses in manger, except for this one:

https://github.com/ultravioletrs/cocos/blob/main/agent/algorithm/logging.go#L68-L70

Since it is unique.

Copy link
Contributor

Choose a reason for hiding this comment

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

define all of them in a list including that one

ms.qemuCfg.VSockConfig.Vnc++

ms.publishEvent("vm-provision", c.Id, "complete", json.RawMessage{})
ms.publishEvent("vm-provision", c.Id, agent.Completed.String(), json.RawMessage{})
Copy link
Contributor

Choose a reason for hiding this comment

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

also set a typed constant for manager states, i.e vm-provision, vm-running, ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We only have two states for manager states, vm provision and stop computation

Copy link
Contributor

Choose a reason for hiding this comment

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

there are additional states, see vm package and qemu package

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
const (
VmProvision ManagerState = iota
StopComputation
Starting
Copy link
Contributor

Choose a reason for hiding this comment

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

state and status are different

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
}

if err := s.EventSvc.SendEvent("algorithm-run", "error", json.RawMessage{}); err != nil {
if err := s.EventSvc.SendEvent(manager.AlgorithmRun.String(), manager.Error.String(), json.RawMessage{}); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

algo run should be in agent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we move this to agent package, importing it here will result in an import cycle hence that will return us to using a string literal.

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
}

if err := s.EventSvc.SendEvent("algorithm-run", "error", json.RawMessage{}); err != nil {
if err := s.EventSvc.SendEvent("AlgorithmRun", manager.Error.String(), json.RawMessage{}); err != nil {
Copy link
Contributor

@SammyOina SammyOina Sep 17, 2024

Choose a reason for hiding this comment

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

should be a constant, also avoid imports from manager on agent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is pkg/manager and not manager package. Also, what do you mean by should be a string?

Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
@dborovcanin dborovcanin merged commit c14a633 into ultravioletrs:main Sep 17, 2024
1 check passed
@WashingtonKK WashingtonKK deleted the prism-441 branch September 17, 2024 13:58
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

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载