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

Connect probers and notifiers by Channel #108

Merged
merged 13 commits into from
May 27, 2022
Merged

Connect probers and notifiers by Channel #108

merged 13 commits into from
May 27, 2022

Conversation

haoel
Copy link
Contributor

@haoel haoel commented May 24, 2022

This PR introduces the channel to connect the probers and notifiers.

For more information, please take a look the discussion #82

Example:

if we have the following configuration

http: 
   - name: probe A
     channels : [ Chann_A, Chann_B]
shell:
   - name: probe B
     channels: [ Chann_C ]
notify:
   - discord: Discord
     channels: [Chann_A, Chann_C]
   - email: Gmail
     channels: [Chann_B]

Then, we will have the following diagram

┌───────┐          ┌─────────┐
│Probe B├─────────►│ Chann_C ├─────┐
└───────┘          └─────────┘     │
                                   │
                                   │
                   ┌─────────┐     │    ┌─────────┐
            ┌─────►│ Chann_A ├─────▼────► Discord │
            │      └─────────┘          └─────────┘
┌───────┐   │
│Probe A├───┤
└───────┘   │
            │      ┌─────────┐          ┌─────────┐
            └─────►│ Chann_B ├──────────►  Gmail  │
                   └─────────┘          └─────────┘

Test

I've done the following test:

  • Case 1: backward compatibility - NO channels defined for all probers and notifiers.
  • Case 2 : 1 prober -> 1 channel -> 1 notifier.
  • Case 3: 5 probers and 3 notifiers, define 3 channels.
  • Case 4: the channel hasn't probers. - everything's fine, but a warning message in the log
  • Case 5: the channel hasn't notifiers - everything's fine, but a warning message in the log.
  • Case 6: the probers and notifiers without channels that can be connected together.

@haoel haoel changed the title [WIP] Connect probers and notifiers by Channel Connect probers and notifiers by Channel May 25, 2022
@haoel haoel requested review from zhao-kun and proditis May 25, 2022 05:49
@haoel haoel marked this pull request as ready for review May 25, 2022 05:49
Copy link
Collaborator

@proditis proditis left a comment

Choose a reason for hiding this comment

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

LGTM but maybe wait for another reviewer as these changes where a bit too much for my Go knowledge, and i'm not sure i fully understood the code. Will do a build/run test shortly and update with any details I find.

Well done @haoel

README.md Outdated Show resolved Hide resolved
@@ -59,6 +59,8 @@ const (
DefaultProbeInterval = time.Second * 60
// DefaultTimeOut is 30 seconds
DefaultTimeOut = time.Second * 30
// DefaultChannelName is the default wide channel name
DefaultChannelName = "__EaseProbe_Channel__"
Copy link
Collaborator

Choose a reason for hiding this comment

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

what will happen if i define this as a channel name or i define a probe to use it like
channels: [ __EaseProbe_Channel__ ] ?

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 would be considered the default channel, it would be grouped with all of the probers and notifiers who have not defined the channel.

@zhao-kun
Copy link
Contributor

zhao-kun commented May 25, 2022

What's the problem the PR will solve?

If we want to let users can config which notification can be applied to the prober, I don't think we should expose the channel concept to the end-user, because it's technical and not intuitive. Can we give the notification a name and let it be referred in one or more probers?

@haoel
Copy link
Contributor Author

haoel commented May 25, 2022

What's the problem the PR will solve?

If we want to let users can config which notification can be applied to the prober, I don't think we should expose the channel concept to the end-user, because it's technical and not intuitive. Can we give the notification a name and let it be referred in one or more probers?

The channel is not the Go concept, it's the channel literally.

To design like this, we have several considerations.

  1. The requirement needs to group the notifiers, then the probers can just send the result to that group.
  2. if we configure the reference of notifiers in the probe, this would couple the notify to probe. Although it works, but in some cases, it could bring complexity. for example, if we want to add or delete a notifier, we need to change many places.

Theoretically, this is an N x M relationship model, introducing a referring object would be the best practice.

You can take a look the discussion #82 to have more information.

Co-authored-by: Pantelis Roditis <[email protected]>
@zhao-kun
Copy link
Contributor

zhao-kun commented May 25, 2022

What's the problem the PR will solve?
If we want to let users can config which notification can be applied to the prober, I don't think we should expose the channel concept to the end-user, because it's technical and not intuitive. Can we give the notification a name and let it be referred in one or more probers?

The channel is not the Go concept, it's the channel literally.

To design like this, we have several considerations.

  1. The requirement needs to group the notifiers, and probers just send the result to that group.
  2. if we configure the reference of notifiers in the probe, this would couple the notify to probe. it works, in some cases, it could bring complexity. for example, if we want to add or delete a notifier, we need to change many places.

Theoretically, this is an N x M relationship model, introducing a referring object would be the best practice.

You can take a look the discussion #82 to have more information.

OK, got it. It's better to relate the issue with the PR in its description. So reviewers can easy to know the background of the PR.

BTW, Why don't we choose the labels and selector mechanism, the mechanism was practiced and applied in the K8s, and cloud systems widely.

channel/channel.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jordy1024 jordy1024 left a comment

Choose a reason for hiding this comment

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

I mainly added some suggestions for improving code readability,for reference only.

cmd/easeprobe/report.go Outdated Show resolved Hide resolved
cmd/easeprobe/report.go Outdated Show resolved Hide resolved
cmd/easeprobe/prober.go Outdated Show resolved Hide resolved
cmd/easeprobe/prober.go Outdated Show resolved Hide resolved
cmd/easeprobe/prober.go Outdated Show resolved Hide resolved
cmd/easeprobe/channel.go Outdated Show resolved Hide resolved
cmd/easeprobe/main.go Show resolved Hide resolved
cmd/easeprobe/main.go Show resolved Hide resolved
cmd/easeprobe/notify.go Outdated Show resolved Hide resolved
cmd/easeprobe/prober.go Outdated Show resolved Hide resolved
@jordy1024
Copy link
Contributor

jordy1024 commented May 25, 2022

What's the problem the PR will solve?
If we want to let users can config which notification can be applied to the prober, I don't think we should expose the channel concept to the end-user, because it's technical and not intuitive. Can we give the notification a name and let it be referred in one or more probers?

The channel is not the Go concept, it's the channel literally.

To design like this, we have several considerations.

  1. The requirement needs to group the notifiers, then the probers can just send the result to that group.
  2. if we configure the reference of notifiers in the probe, this would couple the notify to probe. it works, in some cases, it could bring complexity. for example, if we want to add or delete a notifier, we need to change many places.

Theoretically, this is an N x M relationship model, introducing a referring object would be the best practice.

You can take a look the discussion #82 to have more information.

Sounds like a very flexible, extensible design. 👍🏻

@haoel haoel requested review from localvar and proditis May 26, 2022 01:52
@haoel
Copy link
Contributor Author

haoel commented May 26, 2022

BTW, Why don't we choose the labels and selector mechanism, the mechanism was practiced and applied in the K8s, and cloud systems widely.

It's easy to do the naming work

  • change the notify's channels to labels
  • change the probe's channels to selector

But I think the channels make more sense as the notification just like the TV Channel.

@proditis & @nullsimon, what do you think?

@nullsimon
Copy link
Contributor

BTW, Why don't we choose the labels and selector mechanism, the mechanism was practiced and applied in the K8s, and cloud systems widely.

It's easy to do the naming work

  • change the notify's channels to labels

  • change the probe's channels to selector

But I think the channels make more sense as the notification just like the TV Channel.

@proditis & @nullsimon, what do you think?

Lables and selector are great and commonly used,it's a kv store extension,and channels is just a one feature of them. If we have more new features,it is extensive.

channel/channel.go Outdated Show resolved Hide resolved
@haoel
Copy link
Contributor Author

haoel commented May 26, 2022

I just realize using labels and selector is not just naming works. it's different.

  • For channel, both probe and notify can define that, we just create the channel arbitrarily. So, the code is simpler.
  • For the labels and selector, only the labels can create the labels, and the selector won't and needs to check whether the label exists or not.

cc @zhao-kun @nullsimon @proditis

@zhao-kun
Copy link
Contributor

zhao-kun commented May 26, 2022

BTW, Why don't we choose the labels and selector mechanism, the mechanism was practiced and applied in the K8s, and cloud systems widely.

It's easy to do the naming work

  • change the notify's channels to labels
  • change the probe's channels to selector

But I think the channels make more sense as the notification just like the TV Channel.

@proditis & @nullsimon, what do you think?

IMHO, the term channel represents different ways of sending notification, such as, we could treat email as a channel, SMS as another channel. The label helps us group different channels flexibly. So these terms would be much more intuitive to users and easy to use if we adopt them.

@haoel haoel requested a review from localvar May 26, 2022 04:43
@nullsimon
Copy link
Contributor

I just realize using labels and selector is not just naming works. it's different.

  • For channel, both probe and notify can define that, we just create the channel arbitrarily. So, the code is simpler.

  • For the labels and selector, only the labels can create the labels, and the selector won't and needs to check whether the label exists or not.

cc @zhao-kun @nullsimon @proditis

Yeah,channel is just one dimension,labels and selector become two dimensions. For channel to probers and notifies is that they have a common base metadata,while another become a pub-sub thing. The More extensive the more complex.

@proditis
Copy link
Collaborator

proditis commented May 26, 2022

  • change the notify's channels to labels
  • change the probe's channels to selector

But I think the channels make more sense as the notification just like the TV Channel.

I like the common naming channels more also. i'm not familiar with k8d so i dont know the context the labels and selector keywords are used there.

I dont have strong arguments for or against the change, though, so i leave the final decision to you guys.

@haoel
Copy link
Contributor Author

haoel commented May 26, 2022

First of all, both of them have the same flexibility.

Secondly, I believe different people like different terms, the intuition is subjective.

Channel is business-specific, and Label/Selector is more general. If we want to make business sense, we should use the Channel, otherwise using Label/Selector.

So, we must make the decision here. As the owner and PR author, I will make the final decision - Using the Channel for this version ;-) as this is based on the original discussion, and it's easier for coding work.

Meanwhile, if we need the Label/Selector in the future, we still are open to doing that ...

Copy link
Collaborator

@proditis proditis left a comment

Choose a reason for hiding this comment

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

LGTM

>
> 1) If you don't define the Channel, the default channel will be used for these probers and notifiers. The default channel name is `__EaseProbe_Channel__`
>
> 2) Versions of EaseProbe prior to v1.5.0, do not support the `channel` feature
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can remove the note from this spot and add it to the release notes of the next version.

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 is the major important feature, I think it's better to mention it in the user manual. like other software.

```YAML
http:
- name: probe A
channels : [ Dev_Channel, Manager_Channel ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do the channel names need to follow any particular rules?
Such as no space, no symbols etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks like the limitation is just only for yaml file. If the chars can be accepted by yaml, then we can support that.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
haoel and others added 4 commits May 26, 2022 18:34
Co-authored-by: Pantelis Roditis <[email protected]>
Co-authored-by: Pantelis Roditis <[email protected]>
Co-authored-by: Pantelis Roditis <[email protected]>
@haoel haoel merged commit e6ab189 into megaease:main May 27, 2022
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.

None yet

6 participants