Skip to content

Commit c7f139a

Browse files
committed
continued development of the company enrich handler
1 parent 3c69e93 commit c7f139a

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

engine/plugins/api/aviato/company_enrich.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,17 @@ func (ce *companyEnrich) check(e *et.Event) error {
4848
return err
4949
}
5050

51-
var o *dbt.Entity
52-
var data *companyEnrichResult
51+
var orgent *dbt.Entity
5352
if support.AssetMonitoredWithinTTL(e.Session, e.Entity, ce.plugin.source, since) {
54-
o = ce.lookup(e, e.Entity, since)
55-
} else {
56-
o, data = ce.query(e, e.Entity, keys)
57-
if data != nil {
58-
support.MarkAssetMonitored(e.Session, e.Entity, ce.plugin.source)
59-
}
53+
orgent = ce.lookup(e, e.Entity, since)
54+
} else if o, data := ce.query(e, e.Entity, keys); data != nil {
55+
orgent = o
56+
ce.store(e, o, data)
57+
support.MarkAssetMonitored(e.Session, e.Entity, ce.plugin.source)
6058
}
6159

62-
if o != nil {
63-
ce.process(e, e.Entity, o)
60+
if orgent != nil {
61+
ce.process(e, e.Entity, orgent)
6462
}
6563
return nil
6664
}
@@ -116,6 +114,10 @@ func (ce *companyEnrich) query(e *et.Event, ident *dbt.Entity, apikey []string)
116114
return orgent, enrich
117115
}
118116

117+
func (ce *companyEnrich) store(e *et.Event, orgent *dbt.Entity, data *companyEnrichResult) {
118+
119+
}
120+
119121
func (ce *companyEnrich) process(e *et.Event, ident, orgent *dbt.Entity) {
120122
o := orgent.Asset.(*org.Organization)
121123

engine/plugins/api/aviato/plugin.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,22 @@ func (a *aviato) Start(r et.Registry) error {
6767
return err
6868
}
6969

70+
a.companyEnrich = &companyEnrich{
71+
name: a.name + "-Company-Enrich-Handler",
72+
plugin: a,
73+
}
74+
75+
if err := r.RegisterHandler(&et.Handler{
76+
Plugin: a,
77+
Name: a.companyEnrich.name,
78+
Priority: 6,
79+
Transforms: []string{string(oam.Organization)},
80+
EventType: oam.Identifier,
81+
Callback: a.companyEnrich.check,
82+
}); err != nil {
83+
return err
84+
}
85+
7086
a.log.Info("Plugin started")
7187
return nil
7288
}

engine/plugins/api/aviato/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type aviato struct {
2121
log *slog.Logger
2222
rlimit *rate.Limiter
2323
companySearch *companySearch
24+
companyEnrich *companyEnrich
2425
employees *employees
2526
source *et.Source
2627
}

0 commit comments

Comments
 (0)