Skip to content

Commit

Permalink
OTT-54: Removing Bidder Config
Browse files Browse the repository at this point in the history
  • Loading branch information
pm-viral-vala committed Jan 8, 2021
1 parent 12a8711 commit 661db68
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ import (
"github.com/golang/glog"
)

//Flags of each tag bidder
type Flags struct {
RemoveEmptyParam bool `json:"remove_empty,omitempty"`
}

//BidderConfig mapper json
type BidderConfig struct {
URL string `json:"url,omitempty"`
Expand Down
14 changes: 9 additions & 5 deletions adapters/tagbidder/bidder_macro.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ type BidderMacro struct {
IBidderMacro

//Configuration Parameters
Conf *config.Adapter
BidderConf *BidderConfig
Conf *config.Adapter
//BidderConf *BidderConfig

//OpenRTB Specific Parameters
Request *openrtb.BidRequest
Expand Down Expand Up @@ -101,19 +101,23 @@ func (tag *BidderMacro) SetAdapterConfig(conf *config.Adapter) {
tag.Conf = conf
}

/*
//SetBidderConfig will set Bidder config
func (tag *BidderMacro) SetBidderConfig(conf *BidderConfig) {
tag.BidderConf = conf
}
*/

//GetURI get URL
func (tag *BidderMacro) GetURI() string {
//1. check for impression level URL
//2. check for bidder config level URL
//3. check for adapter config level URL
if len(tag.BidderConf.URL) > 0 {
return tag.BidderConf.URL
}
/*
if nil != tag.BidderConf && len(tag.BidderConf.URL) > 0 {
return tag.BidderConf.URL
}
*/
return tag.Conf.Endpoint
}

Expand Down
7 changes: 6 additions & 1 deletion adapters/tagbidder/ibidder_macro.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ import (
"github.com/PubMatic-OpenWrap/prebid-server/config"
)

//Flags of each tag bidder
type Flags struct {
RemoveEmptyParam bool `json:"remove_empty,omitempty"`
}

//IBidderMacro interface will capture all macro definition
type IBidderMacro interface {
//Helper Function
InitBidRequest(request *openrtb.BidRequest)
LoadImpression(imp *openrtb.Imp) error
GetBidderKeys() map[string]string
SetAdapterConfig(*config.Adapter)
SetBidderConfig(*BidderConfig)
//SetBidderConfig(*BidderConfig)
GetURI() string
GetHeaders() http.Header

Expand Down
4 changes: 2 additions & 2 deletions adapters/tagbidder/macro_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

const (
macroPrefix string = `{{` //macro prefix can not be empty
macroSuffix string = `}}` //macro suffix can not be empty
macroPrefix string = `{` //macro prefix can not be empty
macroSuffix string = `}` //macro suffix can not be empty
macroEscapeSuffix string = `_ESC`
macroPrefixLen int = len(macroPrefix)
macroSuffixLen int = len(macroSuffix)
Expand Down
31 changes: 14 additions & 17 deletions adapters/tagbidder/tagbidder.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
//TagBidder is default implementation of ITagBidder
type TagBidder struct {
adapters.Bidder
bidderName string
bidderConfig *BidderConfig
bidderName string
//bidderConfig *BidderConfig
adapterConfig *config.Adapter
}

Expand All @@ -23,24 +23,19 @@ func NewTagBidder(bidderName openrtb_ext.BidderName, config config.Adapter) (*Ta
obj := &TagBidder{
bidderName: string(bidderName),
adapterConfig: &config,
bidderConfig: GetBidderConfig(string(bidderName)),
}
if nil == obj.bidderConfig {
return nil, errors.New(`missing bidder config`)
//bidderConfig: GetBidderConfig(string(bidderName)),
}
/*
if nil == obj.bidderConfig {
return nil, errors.New(`missing bidder config`)
}
*/
return obj, nil
}

//NewTestTagBidder is an constructor for TagBidder
func NewTestTagBidder(bidderName openrtb_ext.BidderName, config config.Adapter) *TagBidder {
obj := &TagBidder{
bidderName: string(bidderName),
adapterConfig: &config,
bidderConfig: GetBidderConfig(string(bidderName)),
}
if nil == obj.bidderConfig {
return nil
}
obj, _ := NewTagBidder(bidderName, config)
return obj
}

Expand All @@ -60,8 +55,8 @@ func (a *TagBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.
macroProcessor := NewMacroProcessor(bidderMacro, bidderMapper)

//Setting config parameters
//bidderMacro.SetBidderConfig(a.bidderConfig)
bidderMacro.SetAdapterConfig(a.adapterConfig)
bidderMacro.SetBidderConfig(a.bidderConfig)
bidderMacro.InitBidRequest(request)

requestData := []*adapters.RequestData{}
Expand All @@ -75,7 +70,8 @@ func (a *TagBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.
macroProcessor.SetBidderKeys(bidderKeys)
fmt.Printf("\n[V2] Bidder Keys:%v", bidderKeys)

uri := macroProcessor.ProcessURL(bidderMacro.GetURI(), a.bidderConfig.Flags)
//uri := macroProcessor.ProcessURL(bidderMacro.GetURI(), a.bidderConfig.Flags)
uri := macroProcessor.ProcessURL(bidderMacro.GetURI(), Flags{RemoveEmptyParam: true})

requestData = append(requestData, &adapters.RequestData{
ImpIndex: i,
Expand All @@ -91,7 +87,8 @@ func (a *TagBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.
//MakeBids makes bids
func (a *TagBidder) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) {
//response validation can be done here independently
handler, err := GetResponseHandler(a.bidderConfig.ResponseType)
//handler, err := GetResponseHandler(a.bidderConfig.ResponseType)
handler, err := GetResponseHandler(VASTTagResponseHandlerType)
if nil != err {
return nil, []error{err}
}
Expand Down
2 changes: 2 additions & 0 deletions openrtb_ext/bidders.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ var BidderMap = map[string]BidderName{
"zeroclickfraud": BidderZeroClickFraud,
}

/*
//TagBidderMap contains list of tag based bidders
var TagBidderMap = map[string]BidderName{
"spotx": BidderSpotX,
}
*/

// BidderList returns the values of the BidderMap
func BidderList() []BidderName {
Expand Down
13 changes: 6 additions & 7 deletions router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/PubMatic-OpenWrap/prebid-server/adapters/pulsepoint"
"github.com/PubMatic-OpenWrap/prebid-server/adapters/rubicon"
"github.com/PubMatic-OpenWrap/prebid-server/adapters/sovrn"
"github.com/PubMatic-OpenWrap/prebid-server/adapters/tagbidder"
"github.com/PubMatic-OpenWrap/prebid-server/analytics"
analyticsConf "github.com/PubMatic-OpenWrap/prebid-server/analytics/config"
"github.com/PubMatic-OpenWrap/prebid-server/cache"
Expand Down Expand Up @@ -246,12 +245,12 @@ func New(cfg *config.Configuration, rateConvertor *currencies.RateConverter) (r
if err != nil {
glog.Fatalf("Failed to create the bidder params validator. %v", err)
}

err = tagbidder.InitTagBidderConfig(tagBidderSchemaDirectory, openrtb_ext.TagBidderMap)
if err != nil {
glog.Fatalf("Failed to create the tag bidder config. %v", err)
}

/*
err = tagbidder.InitTagBidderConfig(tagBidderSchemaDirectory, openrtb_ext.TagBidderMap)
if err != nil {
glog.Fatalf("Failed to create the tag bidder config. %v", err)
}
*/
p, _ := filepath.Abs(infoDirectory)
bidderInfos := adapters.ParseBidderInfos(cfg.Adapters, p, openrtb_ext.BidderList())

Expand Down

0 comments on commit 661db68

Please sign in to comment.