Skip to content

Allow job/token name to be different than component name? #12

Open
@imricardoramos

Description

@imricardoramos

Should the lib be able to send a batch request for the same component, but with different props?
Eg, I was trying to do the following request:

{
  "Job1": {
    "name": "MyComponent",
    "data": {
      "title": "Foo",
      "content": "foo"
    }
  },
  "Job2": {
    "name": "MyComponent",
    "data": {
      "title": "Bar",
      "content": "bar"
    }
  }
}

However, I can only do this:

html = renderer.render({
    'MyComponent': {
        'title': 'Foo',
        'content': 'foo'
    },
    'MyComponent': {
        'title': 'Bar',
        'content': 'bar'
    }
})

which makes the first job be overridden by the second job because they have same component name (https://github.com/ornj/hypernova-python/blob/master/hypernova/__init__.py#L53).

I've taken a quick look at the nodejs and the ruby clients, and it seems they do it differently:

In Ruby (https://github.com/airbnb/hypernova-ruby/blob/master/lib/hypernova/batch.rb#L45), they make an array of jobs, and then make a hash with the keys being the index of the job in the array.

In Node(https://github.com/airbnb/hypernova-node/blob/master/src/index.js#L89), they use the component name as the job name (as in this lib)

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions