Skip to content

Adding New Attributes to The Agent Configuration

Alejandro Peralta edited this page Nov 10, 2015 · 4 revisions

So you started using bidderd and now you need to add some attributes to your agent's configuration.

You add that attribute to the agents.json file. For example:

[{
"name": "smith",
"config" : {
    ... etc ...
    "bidProbability" : 0.9,
    "providerConfig" : {   // we are adding this one
        "rubicon": {
            "cid": "<some number>",
            "adm": "<some markup>",
            ... etc ...
         }
     },
},
...

And you start bidderd and it doesn't work. You curl into the ACS, but the configuration for "smith" doesn't display the provider config. And that is because, you also have to add it in the type definition of AgentConfig

You have to edit AgentConfig to something like this:

type ProviderConfig struct {
	Cid    int    `json:"cid"`
	Adm    string `json:"adm"`
	// ... etc ..
}

type AgentConfig struct {
	// We use `RawMessage` for Augmentations and BidcControl, because we
	// don't need it, we just cache it.
	Account            []string         `json:"account"`
	Augmentations      *json.RawMessage `json:"augmentations"`
	BidControl         *json.RawMessage `json:"bidControl"`
	BidProbability     float64          `json:"bidProbability"`
	Creatives          []Creative       `json:"creatives"`
	ErrorFormat        string           `json:"errorFormat"`
	External           bool             `json:"external"`
	ExternalId         int              `json:"externalId"`
	LossFormat         string           `json:"lossFormat"`
	MinTimeAvailableMs float64          `json:"minTimeAvailableMs"`
	WinFormat          string           `json:"winFormat"`
	ProviderConf       map[string]ProviderConfig   `json:"providerConfig"`
}

Of course this is one way to do it. You could of course use interface{} or *json.RawMessage but then you would have to parse it/cast it when you use it.

Why aren't all configuration properties already in the type? It's a good question. :-) Pull requests are welcomed!

Clone this wiki locally