npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ymlr-redis

v1.2.2-alpha.5

Published

Handle redis into ymlr platform

Downloads

126

Readme

ymlr-redis

ymlr-redis for ymlr plugin

Shares

Tag details

| Tags | Description | |---|---| | ymlr-redis | Declare a redis connector | | ymlr-redis'job | Add a new job with input data to do async | | ymlr-redis'onJob | Handle jobs which is add by ymlr-redis'job | | ymlr-redis'pub | Publish a message to channels in redis | | ymlr-redis'remove | Remove callbacks in channels after subscribing | | ymlr-redis'sub | Subscribe channels in redis | | ymlr-redis'unsub | Unsubscribe channels in redis |

ymlr-redis

Declare a redis connector

Example:

  - name: "[redis] localhost"
    ymlr-redis:
      uri: redis://user:pass                  # redis uri
      runs:                                   # When a message is received then it will runs them
        - echo: redis is connected

Publish a message to channels

  - name: "[redis] localhost"
    ymlr-redis:
      uri: redis://user:pass                  # redis uri
      runs:                                   # When a message is received then it will runs them
        - name: Publish a message
          ymlr-redis'pub:
            channels:
              - test
            data:
              msg: Hello world

ymlr-redis'job

Add a new job with input data to do async

Example:

  - name: Crop image size
    ymlr-redis'job:
      uri: redis://user:pass
      opts:                               # ioredis options
      name: Crop Image                    # Queue name
      queueOpts:                          # Job queue options (https://docs.bullmq.io)
      jobOpts:                            # Job options (https://docs.bullmq.io)
        removeOnComplete: true
      data:                               # Job data
        url: http://...
        type: jpeg
        size:
          width: 10
          height: 10

Declare global then reused by code

  - name: Crop image size
    id: processImageJobsProxy
    detach: false                         # Dont release connection, keep it's used in background
    ymlr-redis'job:
      uri: redis://user:pass
      opts:                               # ioredis options
      name: Crop Image                    # Queue name
      queueOpts:                          # Job queue options (https://docs.bullmq.io)
      jobOpts:                            # Job options (https://docs.bullmq.io)
        removeOnComplete: true

  - js: |
      await $vars.processImageJobsProxy.$.add({
        url: 'http://...',
        type: 'jpeg',
        size: {
          width: 10,
          height: 10
        }
      }, {
        removeOnFail: true
      })

ymlr-redis'onJob

Handle jobs which is add by ymlr-redis'job

Example:

  - name: Handle to crop image size
    ymlr-redis'onJob:
      uri: redis://user:pass
      opts:                                 # ioredis options
        maxRetriesPerRequest:
      name: Crop Image                      # Queue name
      workerOpts:                           # Job worker options (https://docs.bullmq.io)
        concurrency: 1
      runs:
        - echo: A new job has justed added
        - echo: ${ $parentState.job }       # Job information
        - echo: ${ $parentState.job.data }  # Job data

ymlr-redis'pub

Publish a message to channels in redis

Example:

Publish a message to redis

  - name: "[redis] localhost"
    ymlr-redis'pub:
      uri: redis://user:pass
      channel: channel1
      channels:
        - channel2
        - channel3
      data:
        name: thanh

Reuse redis connection to publish multiple times

  - name: "[redis] localhost"
    ymlr-redis:
      uri: redis://user:pass
      runs:
        - ymlr-redis'pub:
            channels:
              - channel1
            data:
              name: thanh
        - ...
        # Other elements

Or reuse by global variable Reuse redis connection to publish multiple times

  - name: "[redis] localhost"
    ymlr-redis:
      uri: redis://user:pass
    vars:
      redis1: ${this}

  - ymlr-redis'pub:
      redis: ${ $vars.redis1 }
      channels:
        - channel1
      data:
        name: thanh

ymlr-redis'remove

Remove callbacks in channels after subscribing

Example:

  - id: redis
    name: Global Redis
    ymlr-redis:
      uri: redis://user:pass

  - name: "subscribe a channel1"
    ymlr-redis'sub:
      name: test_channel1
      redis: ${ $vars.redis }
      channel: channel1
      runs:
        - echo: callback 01 ${ $parentState.channelName }

  - name: keep subscribing channels but it removes the handler "test_channel1"
    ymlr-redis'unsub: test_channel1
    # ymlr-redis'unsub: [test_channel1, test_channel2]

ymlr-redis'sub

Subscribe channels in redis

Example:

  - name: "[redis] localhost"
    ymlr-redis'sub:
      uri: redis://user:pass
      type: buffer                            # Message type is in [text, buffer]. Default is "text"
      channel: channel1
      channels:                               # channels which is subscribed
        - channel1
        - channel2
      runs:                                   # When a message is received then it will runs them
        - ${ $parentState }                   # - Received data in a channel
        - ${ $parentState.channelName }       # - channel name
        - ${ $parentState.channelData }       # - Received message which is cast to object
        - ${ $parentState.channelMsg }        # - Received message which is text

        - ...
        # Other elements

        - stop:

Used in global redis

  - name: Global Redis
    ymlr-redis:
      uri: redis://user:pass
      runs:
        - name: "[redis] localhost"
          ymlr-redis'sub:
            type: buffer                        # Message type is in [text, buffer]. Default is "text"
            channel: channel1
            channels:                           # channels which is subscribed
              - channel1
              - channel2
            runs:                               # When a message is received then it will runs them
              - ${ $parentState }               # - Received data in a channel
              - ${ $parentState.channelName }   # - Channel name
              - ${ $parentState.channelData }   # - Received message which is cast to object
              - ${ $parentState.channelMsg }    # - Received message which is text or buffer

              - ...
              # Other elements

Or reuse by global variable

  - id: redis
    name: Global Redis
    ymlr-redis:
      uri: redis://user:pass

  - name: "[redis] localhost"
    ymlr-redis'sub:
      name: my-test-channel                 # channel name which to reused when register again
      redis: ${ $vars.redis }
      channel: channel1
      channels:                             # channels which is subscribed
        - channel1
        - channel2
      runs:                                 # When a message is received then it will runs them
        - ${ $parentState }                 # - Received data in a channel
        - ${ $parentState.channelName }     # - channel name
        - ${ $parentState.channelData }     # - Received message which is cast to object
        - ${ $parentState.channelMsg }      # - Received message which is text

        - ...
        # Other elements

        - stop:                             # - Stop subscribing

  - name: "subscribe channels again after unsubcribed"
    ymlr-redis'sub:
      redis: ${ $vars.redis }
      channel: channel1
      channels:                             # channels which is subscribed again
        - channel2

ymlr-redis'unsub

Unsubscribe channels in redis

Example:

  - id: redis
    name: Global Redis
    ymlr-redis:
      uri: redis://user:pass

  - name: "[redis] localhost"
    ymlr-redis'unsub:
      redis: ${ $vars.redis }
      channel: channel1
      channels:                             # channels which are unsubscribed
        - channel1
        - channel2

Have fun :)