openwrap

package
v4.0.0-...-d1dbf83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 92 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdAttrWireEngageToClose     = 1
	AdAttrWireTrueDoubleEndCard = 2
	AdAttrWireCTAOverlay        = 3
	AdAttrWireMRAIDAppStatus    = 4
	AdAttrWireCountdownOverlay  = 5
	AdAttrWireFrcClkBrowser     = 6
)

Wire IDs for ext.owsdk.adattributes (numeric; product spec).

View Source
const (
	MRECWidth  = 300
	MRECHeight = 250

	// Server injects format-level ext.owsdk.adattributes only for displaymanagerver in [4.1.0, 5.3.0].
	// SDK 5.4.0+ sends format-level owsdk in signal; OpenWrap merges from signal instead.
	OWSDKServerAdAttributesMinSDKVersion = "4.1.0"
	OWSDKServerAdAttributesMaxSDKVersion = "5.3.0"

	// SDK 5.4.0+ includes format-level ext.owsdk (e.g. adattributes) in decoded signal banner/video ext.
	OWSDKSignalFormatLevelMinSDKVersion = "5.4.0"
)
View Source
const (
	OpenWrapAuction      = "/pbs/openrtb2/auction"
	OpenWrapV25          = "/openrtb/2.5"
	OpenWrapV25Video     = "/openrtb/2.5/video"
	OpenWrapOpenRTBVideo = "/video/openrtb"
	OpenWrapVAST         = "/video/vast"
	OpenWrapJSON         = "/video/json"
	OpenWrapAmp          = "/amp"
)
View Source
const (
	CACHE_EXPIRY_ROUTINE_RUN_INTERVAL = 1 * time.Minute
)

Variables

View Source
var GetRandomNumberBelow100 = func() int {
	return rand.Intn(99)
}
View Source
var GetRandomNumberIn1To100 = func() int {
	return rand.Intn(100) + 1
}

Functions

func ABTestProcessing

func ABTestProcessing(rctx models.RequestCtx) (map[int]map[string]string, bool)

ABTestProcessing function checks if test config should be applied and change the partner config accordingly

func AppendTest

func AppendTest(key string) string

AppendTest appends "_test" string to given key

func ApplyOWSDKFormatLevelAdAttributes

func ApplyOWSDKFormatLevelAdAttributes(imp *openrtb2.Imp, impCtx models.ImpCtx, deviceOS string) error

ApplyOWSDKFormatLevelAdAttributes sets imp.banner|video ext.owsdk.adattributes from unifiedFeatureMatrix for displaymanagerver 4.1.0–5.3.0 only. imp.native is skipped.

func ApplyTestConfig

func ApplyTestConfig(rctx models.RequestCtx) bool

ApplyTestConfig checks if test config should be applied

func Builder

func Builder(rawCfg json.RawMessage, deps moduledeps.ModuleDeps) (interface{}, error)

init openwrap module and its dependecies like config, cache, db connection, bidder cfg, etc.

func CheckABTestEnabled

func CheckABTestEnabled(rctx models.RequestCtx) bool

CheckABTestEnabled checks whether a given request is AB test enabled or not

func CheckWinningBidId

func CheckWinningBidId(bidId string, wbidIds []string) bool

func CreateOWSDKExtension

func CreateOWSDKExtension(wireIDs []int) map[string]any

CreateOWSDKExtension builds ext.owsdk with sorted, deduplicated, positive adattribute wire IDs.

func ExtractCTAOverlayFromVASTFastXML

func ExtractCTAOverlayFromVASTFastXML(adm string) (json.RawMessage, bool)

ExtractCTAOverlayFromVASTFastXML parses adm with the FastXML handler and returns ctaoverlay as json.RawMessage for direct injection (e.g. into bid.ext.owsdk.ctaoverlay). It creates the handler, calls Parse(adm), then getCTAOverlayFromFastXMLHandler(h).

func GetAdapterThrottleMap

func GetAdapterThrottleMap(partnerConfigMap map[int]map[string]string, adapterThrottleMap map[string]struct{}) (map[string]struct{}, bool)

GetAdapterThrottleMap creates a map of adapters that should be throttled and returns whether all partners are throttled.

func GetEndpoint

func GetEndpoint(path, source string, agent string) string

func GetHostName

func GetHostName() string

getHostName Generates server name from node and pod name in K8S environment

func GetInt

func GetInt(val interface{}) int

GetInt converts interface to int if it is compatible

func GetIntArray

func GetIntArray(val interface{}) []int

GetIntArray converts interface to int array if it is compatible

func GetOpenWrapPrometheusServer

func GetOpenWrapPrometheusServer(cfg *config.Configuration, gatherer *prometheus.Registry, server *http.Server) *http.Server

func GetRequestIP

func GetRequestIP(body []byte, request *http.Request) string

func GetRequestUserAgent

func GetRequestUserAgent(body []byte, request *http.Request) string

func GetSupportedAdAttributeWireIDs

func GetSupportedAdAttributeWireIDs(os OS, sdkVersion string, adFormat AdFormat) []int

GetSupportedAdAttributeWireIDs returns the supported ext.owsdk.adattributes wire IDs for the given OS, SDK version, and ad format.

Callers are expected to pass a trimmed and validated SDK version (currently supported range: [4.1.0, 5.3.0]).

func GetTargettingForAdpod

func GetTargettingForAdpod(bid openrtb2.Bid, partnerConfig map[string]string, impCtx models.ImpCtx, bidCtx models.BidCtx, seat string) map[string]string

func GetTargettingForDebug

func GetTargettingForDebug(rctx models.RequestCtx, bidID, tagID string, bidCtx models.BidCtx) map[string]string

func Handler

func Handler(w http.ResponseWriter, r *http.Request)

Handler for /geo endpoint

func IsAlias

func IsAlias(bidder string) (string, bool)

IsAlias will return copy of exisiting alias

func IsVideoBidEligibleForCTAOverlay

func IsVideoBidEligibleForCTAOverlay(bidExt *models.BidExt, ctaOverlayRequested bool, displayManagerVer string) bool

IsVideoBidEligibleForCTAOverlay returns true when we should parse adm and inject bid.ext.owsdk.ctaoverlay.

func MergeSignalFormatLevelOWSDK

func MergeSignalFormatLevelOWSDK(imp *openrtb2.Imp, signalRequest *openrtb2.BidRequest, sdkVersion string) error

MergeSignalFormatLevelOWSDK copies format-level ext.owsdk from decoded SDK signal onto the request imp when displaymanagerver >= 5.4.0. v25 requests already carry format-level owsdk on the imp and do not use signal. For SDK < 5.4.0 this is a no-op (server injection handles 4.1.0–5.3.0).

func PrometheusHandler

func PrometheusHandler(reg prometheus.Gatherer, timeDur time.Duration, endpoint string) http.Handler

func RecordPublisherPartnerNoCookieStats

func RecordPublisherPartnerNoCookieStats(rctx models.RequestCtx)

RecordPublisherPartnerNoCookieStats parse request cookies and records the stats if cookie is not found for partner

func ThrottleAdapter

func ThrottleAdapter(partnerConfig map[string]string) bool

ThrottleAdapter this function returns bool value for whether a adapter should be throttled or not

func TrimRightByte

func TrimRightByte(s string, b byte) string

func UpdateImpProtocols

func UpdateImpProtocols(impProtocols []adcom1.MediaCreativeSubtype) []adcom1.MediaCreativeSubtype

func UpdateTestConfig

func UpdateTestConfig(rctx models.RequestCtx) map[int]map[string]string

UpdateTestConfig returns the updated partnerconfig according to the test type

func UpdateUserExtWithValidValues

func UpdateUserExtWithValidValues(user *openrtb2.User)

func ValidateEIDs

func ValidateEIDs(eids []openrtb2.EID) []openrtb2.EID

Types

type AdFormat

type AdFormat string

AdFormat is a matrix row key: OS + SDK range + slot-specific logical format (Approach 2 request spec).

const (
	AdFormatInterstitialDisplay AdFormat = "interstitial_display" // instl=1 && banner — banner.ext
	AdFormatInterstitialVideo   AdFormat = "interstitial_video"   // instl=1 && video — video.ext
	AdFormatRewardedVideo       AdFormat = "rewarded_video"       // reward=1 && video — video.ext
	AdFormatMRECDisplay         AdFormat = "mrec_display"         // instl=0, banner, MREC size — banner.ext
	AdFormatMRECVideo           AdFormat = "mrec_video"           // instl=0, video, MREC size — video.ext
	AdFormatBannerDisplay       AdFormat = "banner_display"       // instl=0, banner, non-MREC — banner.ext
)

func DetermineAdFormatForBanner

func DetermineAdFormatForBanner(impCtx models.ImpCtx) AdFormat

DetermineAdFormatForBanner maps imp.banner to a matrix row (Approach 2 request spec):

  • Interstitial display: instl == 1 && imp.banner != nil (effective)
  • MREC display: instl == 0 or absent && imp.banner != nil (effective) && isMRECSize()
  • Banner display: instl == 0 or absent && imp.banner != nil (effective) && !isMRECSize()

func DetermineAdFormatForVideo

func DetermineAdFormatForVideo(impCtx models.ImpCtx) AdFormat

DetermineAdFormatForVideo maps imp.video to a matrix row (Approach 2 request spec):

  • Rewarded video: reward == 1 && imp.video != nil (effective)
  • Interstitial video: instl == 1 && imp.video != nil (effective)
  • MREC video: isMRECVideo (instl == 0 or absent && imp.video != nil && imp.video is 300×250)

type FeatureConfig

type FeatureConfig struct {
	OS         OS
	MinVersion string
	MaxVersion string
	AdFormat   AdFormat
	WireIDs    []int
}

FeatureConfig defines supported ext.owsdk adattribute wire IDs for OS, SDK version, and ad format. MinVersion and MaxVersion are inclusive; MaxVersion empty means no upper bound (min only). 5.1.0–5.3.0 bands use sdk510–sdk530 range rows.

type OS

type OS string

OS represents the operating system

const (
	OSAndroid OS = "android"
	OSiOS     OS = "ios"
)

func DetermineOS

func DetermineOS(deviceOS string) OS

DetermineOS determines the OS based on device information

type OpenWrap

type OpenWrap struct {
	// contains filtered or unexported fields
}

func (OpenWrap) GetCache

func (ow OpenWrap) GetCache() cache.Cache

GetCache Temporary function to expose cache to SSHB

func (OpenWrap) GetConfig

func (ow OpenWrap) GetConfig() config.Config

GetConfig Temporary function to expose config to SSHB

func (*OpenWrap) GetFeature

func (ow *OpenWrap) GetFeature() publisherfeature.Feature

GetFeature Temporary function to expose feature to SSHB

func (OpenWrap) GetMetricEngine

func (ow OpenWrap) GetMetricEngine() metrics.MetricsEngine

GetMetricEngine Temporary function to expose mertics to SSHB

func (OpenWrap) HandleBeforeValidationHook

changes to init the request ctx with profile and request details

func (OpenWrap) HandleEntrypointHook

temporary openwrap changes to support non-pbs apis like openrtb/2.5, openrtb/amp, etc temporary openwrap changes to support non-ortb fields like request.ext.wrapper

func (OpenWrap) HandleRawBidderResponseHook

HandleRawBidderResponseHook fetches rCtx and check for vast unwrapper flag to enable/disable vast unwrapping feature

func (*OpenWrap) SetCache

func (ow *OpenWrap) SetCache(c cache.Cache)

GetCache Temporary function to expose cache to SSHB

func (*OpenWrap) SetConfig

func (ow *OpenWrap) SetConfig(c config.Config)

SetConfig Temporary function to expose config to SSHB

func (*OpenWrap) SetMetricEngine

func (ow *OpenWrap) SetMetricEngine(m metrics.MetricsEngine)

GetMetricEngine Temporary function to expose mertics to SSHB

func (OpenWrap) Shutdown

func (m OpenWrap) Shutdown() error

Shutdown stops background goroutines owned by OpenWrap (e.g. APS OW mapping DB refresh ticker).

type SupplyChainConfig

type SupplyChainConfig struct {
	Validation  string                `json:"validation"`
	SupplyChain *openrtb2.SupplyChain `json:"config"`
}

SupplyChainConfig reads profile level supply chain object from database

Directories

Path Synopsis
mock
Package mock_cache is a generated GoMock package.
Package mock_cache is a generated GoMock package.
mock
Package mock_database is a generated GoMock package.
Package mock_database is a generated GoMock package.
mock_driver
Package mock_driver is a generated GoMock package.
Package mock_driver is a generated GoMock package.
endpoints
Package geodb provides an interface for performing IP-to-geography lookups using a GeoIP database
Package geodb provides an interface for performing IP-to-geography lookups using a GeoIP database
mock
Package mock_geodb is a generated GoMock package.
Package mock_geodb is a generated GoMock package.
netacuity
Package netacuity offers methods for initializing a GeoIP database client and to perform the ip-to-geo lookup functionality.
Package netacuity offers methods for initializing a GeoIP database client and to perform the ip-to-geo lookup functionality.
mock
Package mock_metrics is a generated GoMock package.
Package mock_metrics is a generated GoMock package.
stats/mock
Package mock_stats is a generated GoMock package.
Package mock_stats is a generated GoMock package.
middleware
nbr
mock
Package mock_profilemetadata is a generated GoMock package.
Package mock_profilemetadata is a generated GoMock package.
Package tbf provides functionalities related to the Tracking-Beacon-First (TBF) feature.
Package tbf provides functionalities related to the Tracking-Beacon-First (TBF) feature.
mock
Package mock_publisherfeature is a generated GoMock package.
Package mock_publisherfeature is a generated GoMock package.
sdk
aps
mock
Package mock_wakanda is a generated GoMock package.
Package mock_wakanda is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址