hupili / snsapi

Cross platform middleware for Social Networking Services: Twitter, Facebook, SinaWeibo, Renren, RSS, Email, Sqlite, ... (more coming)
http://snsapi.ie.cuhk.edu.hk
159 stars 53 forks source link

Upgrade of channel.json #94

Open hupili opened 10 years ago

hupili commented 10 years ago

channel.json needs upgrade in order to incorporate more channel related information, e.g. rate limit confs (#25).

Original design used a list as outmost layer.... We will change it to a dict so that further extensions are transparent. Put in v1 for this interface change. The channels field will also be a dict instead of a list.

One prototype of rate limit is in sina-automator.

The full fledged channel.json may look like:

{
  "channels": {
    "ch1": {
      "channel_name": "ch1",
      "open": "yes",
      "methods": {
        "home_timeline": {
          "default_parameter": {
            "count": 30
          },
          "resource_consumption": {
            "ip": 1,
            "user1": 1,
            "app1": 1
          }
        },
        "update": {...},
        "forward": {...},
        "reply": {...}
      }
    },
    "ch2": {...},
    "ch3": {...}
  }
  "resources": {
    "ip": {
      "max": 100,
      "init": 1,
      "rate": 2
    },
    "user1": {
      ...
    },
    "user2": {
      ...
    },
    ...
    "app1": {
      ...
    },
    "app2": {
      ...
    }
  }
}

This looks hairy... I may hold back the integration of rate limit in channel.json. Those can be put into another separate conf resource.json. Since rate limit is only valid in async mode, separating them may be a better idea. Users can start with a minimum channel.json and add more ingredients later if needed.

In an afterthought, channels: [] may be better. This is to enable fast generation of a min conf: