'Capturing events in eventBridge that don't match any rule

I am trying to find a way to somehow capture events that do not match a specific rule from an event bus. Below is the event-pattern for a rule that I created:

 {
  "detail": {
      "key1": ["1234"],
      "key2": ["ABC"],
      "key3": ["PHL"]
  }
}

The rule is matched and the target is invoked only if all 3 keys in the pattern are matching.

How do I log or find out the event that was unmatched by this rule and the target wasn't invoked?

Solutions I tried but failed:



Solution 1:[1]

Like what Marcin said ... Its possible to write a Lambda as target with a rule that matches all/most of the events in your EB. The Lambda function will

  1. Loop on ListRules for all events in your custom EB
  2. Foreach rule (not including this new Lambda), do a TestEventPattern
  3. If no matches are found, log to a DLQ

Not a pretty soln I admit ...

See:

https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_ListRules.html https://docs.aws.amazon.com/eventbridge/latest/APIReference/API_TestEventPattern.html

Solution 2:[2]

i don't want any stutter between transitioning those files

What you are looking for is called "gapless playback". Sadly, this is not currently supported by LibVLC.

Regardless, to play multiple individual files, you need to either feed them one after the other to the mediaplayer (by subscribing to the EndReached event, for example) or use a MediaList object.

Solution 3:[3]

You have picked a complicated and arguably inappropriate code example for your scenario.
Try something like this (without ctypes):

import vlc
import glob
import time

base_folder = './'
# vlc State 0: Nowt, 1 Opening, 2 Buffering, 3 Playing, 4 Paused, 5 Stopped, 6 Ended, 7 Error
playing = set([1,2,3,4])

def add_media(inst, media_list, playlist):
    for song in playlist:
        print('Loading: - {0}'.format(song))
        media = inst.media_new(song)    
        media_list.add_media(media)
        
playlist = glob.glob(base_folder + "/" + "*.mp3")
playlist = sorted(playlist)
media_player = vlc.MediaListPlayer()
inst = vlc.Instance('--no-xlib --quiet ') 
media_list = vlc.MediaList()
add_media(inst, media_list, playlist)

media_player.set_media_list(media_list)
media_player.play()
time.sleep(0.1)
current = ""
idx = 1
player = media_player.get_media_player()
while True:
    state = player.get_state()
    if state.value == vlc.State.Ended or state == vlc.State.Error:
        if idx == len(playlist)+1:
            break
    title = player.get_media().get_mrl()
    if title != current:
        print("\nPlaying - {0}\t{1} of {2}".format(str(title), idx, len(playlist)))
        current = title
        idx += 1
    time.sleep(0.1)
print("\nPlaylist Finished")    

Here, we use a MediaListPlayer() rather than a media.player_new_from_media() or a media_player_new() because we are playing a set of media, not a single instance.
You can improve on this by controlling it via events using the event_manager() and attaching appropriate events for the player to listen for.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 mfkl
Solution 3 Rolf of Saxony