Documentation
¶
Index ¶
- type Aplicable
- type Condition
- type Detection
- type MapResponse
- type MapResponseAsset
- type Meta
- type RTBRuler
- type RTBRules
- func (r *RTBRules) AdjustImpression(target TargetImpression, imp *adtype.Impression, format *types.Format) error
- func (r *RTBRules) ApplyRules(format *types.Format, isIntr, isPush bool, fn func(rule *RuleItem) error) error
- func (r *RTBRules) Detect(sig RequestSignal) *Detection
- func (r *RTBRules) HasMappingRules() bool
- func (r *RTBRules) IsFormatSupport(format *types.Format) bool
- func (r *RTBRules) IsInterstitialSupport(format *types.Format) bool
- func (r *RTBRules) IsPushSupport(format *types.Format) bool
- func (r *RTBRules) NoRequestObject(format *types.Format, isIntr, isPush bool) bool
- type RequestSignal
- type ResponseSpec
- type RuleConfig
- type RuleItem
- type TargetImpression
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Aplicable ¶
type Aplicable int8
func (Aplicable) MarshalJSON ¶
func (Aplicable) UnmarshalJSON ¶
func (*Aplicable) UnmarshalText ¶
type Condition ¶
type Condition struct {
Formats []string `json:"formats,omitempty"`
Interstitial Aplicable `json:"interstitial,omitempty"`
Push Aplicable `json:"push,omitempty"`
// Objects restricts DSP Detect to an impression shape. Empty means any shape.
// Tokens: banner, video, native, interstitial, none.
Objects []string `json:"objects,omitempty"`
}
type Detection ¶
type Detection struct {
FormatCodes []string
Interstitial bool
Push bool
NoRequestObject bool
Rule *RuleItem
}
Detection is the inverted match: partner Ext → format codes and flags.
type MapResponse ¶
type MapResponse struct {
Assets []MapResponseAsset `json:"assets,omitempty"`
// contains filtered or unexported fields
}
MapResponse defines how native response assets are mapped to content fields.
func (*MapResponse) HasAssets ¶
func (mr *MapResponse) HasAssets() bool
HasAssets returns true if the MapResponse has any assets defined.
func (*MapResponse) Mapping ¶
Mapping iterates over all assets, resolves each asset's Field path inside data using pre-split segments, and calls fnk with the asset and the resolved value (nil when the path does not exist or leads through a non-map node). Segment splitting is done once on the first call; subsequent calls are allocation-free for the path traversal itself. Iteration stops on the first non-nil error returned by fnk.
type MapResponseAsset ¶
type MapResponseAsset struct {
ID int `json:"id"`
Name string `json:"name"`
Field string `json:"field"`
// contains filtered or unexported fields
}
MapResponseAsset maps an OpenRTB native asset ID to a named content field. Field supports nested paths separated by "/" (e.g. "images/main/url"). The parsed path segments are cached on first use to avoid repeated allocations.
type Meta ¶
type Meta struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Version string `json:"version,omitempty"`
ModifiedAt time.Time `json:"modified_at,omitempty"`
Docs []info.Documentation `json:"docs,omitempty"`
}
Meta holds descriptive metadata for an RTBRules set. Fields are informational and may be exposed via API.
type RTBRuler ¶
type RTBRuler interface {
IsFormatSupport(format *types.Format) bool
IsInterstitialSupport(format *types.Format) bool
IsPushSupport(format *types.Format) bool
HasMappingRules() bool
NoRequestObject(format *types.Format, isIntr, isPush bool) bool
ApplyRules(format *types.Format, isIntr, isPush bool, fn func(rule *RuleItem) error) error
AdjustImpression(target TargetImpression, imp *adtype.Impression, format *types.Format) error
Detect(sig RequestSignal) *Detection
}
type RTBRules ¶
type RTBRules struct {
Meta Meta `json:"meta,omitempty"`
Formats []string `json:"formats,omitempty"`
InterstitialFormats []string `json:"interstitial_formats,omitempty"`
PushFormats []string `json:"push_formats,omitempty"`
SSPRules []*RuleItem `json:"ssp_rules,omitempty"`
DSPRules []*RuleItem `json:"dsp_rules,omitempty"`
}
RTBRules defines a set of rules for handling OpenRTB requests. Interstitial and push are considered supported when their respective format lists are explicitly non-empty.
func (*RTBRules) AdjustImpression ¶
func (r *RTBRules) AdjustImpression(target TargetImpression, imp *adtype.Impression, format *types.Format) error
AdjustImpression applies the first matching rule's configuration to the target impression, if any rule matches the given format and impression type.
func (*RTBRules) ApplyRules ¶
func (r *RTBRules) ApplyRules(format *types.Format, isIntr, isPush bool, fn func(rule *RuleItem) error) error
ApplyRules iterates over all rules, applying the provided function to each rule that matches the given format and impression type.
func (*RTBRules) Detect ¶
func (r *RTBRules) Detect(sig RequestSignal) *Detection
Detect returns the first DSPRules entry whose Config.Ext is a subset of the incoming impression Ext and whose Objects, when set, match the impression shape. FormatCodes come from RuleItem.Formats. An empty Ext does not filter, so that rule matches any signal that passes the interstitial and object checks.
Interstitial Exclude + instl skips the rule. Push and Interstitial Include are outputs. reset "instl" forces Interstitial false after that calculation. No match returns nil.
func (*RTBRules) HasMappingRules ¶
HasMappingRules checks if there are any mapping rules defined in the RTBRules configuration.
func (*RTBRules) IsFormatSupport ¶
IsFormatSupport returns true when the format codename is listed in Formats. An empty Formats list or a "*" entry means no restriction — all formats are accepted.
func (*RTBRules) IsInterstitialSupport ¶
IsInterstitialSupport returns true when InterstitialFormats is non-empty and contains the given format codename.
func (*RTBRules) IsPushSupport ¶
IsPushSupport returns true when PushFormats is non-empty and contains the given format codename.
type RequestSignal ¶
RequestSignal is the inbound OpenRTB impression shape used to invert format→Ext rules (DSP ingress).
type ResponseSpec ¶
type ResponseSpec struct {
Render string `json:"render,omitempty"`
}
ResponseSpec chooses how a matched DSP rule is written into the bid.
type RuleConfig ¶
type RuleConfig struct {
Ext map[string]any `json:"ext,omitempty"`
NoRequestObject bool `json:"no_request_object,omitempty"`
}
RuleConfig holds extra parameters passed to the ad exchange for a matched rule.
type RuleItem ¶
type RuleItem struct {
Condition Condition `json:"condition"`
Formats []string `json:"formats,omitempty"`
Config RuleConfig `json:"config"`
MapResponse *MapResponse `json:"map_response,omitempty"`
Response *ResponseSpec `json:"response,omitempty"`
// Reset names parameters cleared after the rule matches. Known token: "instl".
Reset []string `json:"reset,omitempty"`
}
RuleItem represents a single rule in the RTBRules set, consisting of a condition, configuration, and optional response mapping. Formats is the DSP result: allowed ad format codes after condition matches. SSP matching still uses Condition.Formats.