Skip to content

Commit

Permalink
struct ordering for efficient alignment of fields
Browse files Browse the repository at this point in the history
  • Loading branch information
shmsr committed Dec 26, 2023
1 parent 8a26a7d commit 16d8c31
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions x-pack/filebeat/input/salesforce/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import (

type config struct {
Auth *authConfig `config:"auth"`
EventMonitoringMethod *EventMonitoringMethod `config:"event_monitoring_method"`
URL string `config:"url" validate:"required"`
Version int `config:"version" validate:"required"`
InitialInterval time.Duration `config:"initial_interval"`
EventMonitoringMethod *EventMonitoringMethod `config:"event_monitoring_method"`
}

type EventMonitoringMethod struct {
Expand All @@ -25,9 +25,9 @@ type EventMonitoringMethod struct {

type EventMonitoringConfig struct {
Enabled *bool `config:"enabled"`
Interval time.Duration `config:"interval"`
Query *QueryConfig `config:"query"`
Cursor *cursorConfig `config:"cursor"`
Interval time.Duration `config:"interval"`
}

func (e *EventMonitoringConfig) isEnabled() bool {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/filebeat/input/salesforce/config_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (

func TestOAuth2Config(t *testing.T) {
tests := map[string]struct {
config UserPasswordFlow
wantErr error
config UserPasswordFlow
}{
"auth disabled I": {config: UserPasswordFlow{}, wantErr: nil},
"auth disabled II": {config: UserPasswordFlow{Enabled: pointer(false)}, wantErr: nil},
Expand All @@ -35,8 +35,8 @@ func TestOAuth2Config(t *testing.T) {

func TestJWTConfig(t *testing.T) {
tests := map[string]struct {
config JWTBearerFlow
wantErr error
config JWTBearerFlow
}{
"auth disabled I": {config: JWTBearerFlow{}, wantErr: nil},
"auth disabled II": {config: JWTBearerFlow{Enabled: pointer(false)}, wantErr: nil},
Expand Down
8 changes: 4 additions & 4 deletions x-pack/filebeat/input/salesforce/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ func TestFormQueryWithCursor(t *testing.T) {
t.Cleanup(resetTimeNow)

tests := map[string]struct {
initialInterval time.Duration
wantErr error
cursor mapstr.M
defaultSOQLTemplate string
valueSOQLTemplate string
wantQuery string
cursor mapstr.M
wantErr error
initialInterval time.Duration
}{
"valid soql templates with nil cursor": { // expect default query with LogDate > initialInterval
initialInterval: 60 * 24 * time.Hour, // 60 * 24h = 1440h = 60 days = 2 months
Expand Down Expand Up @@ -283,9 +283,9 @@ var _ inputcursor.Publisher = (*publisher)(nil)

type publisher struct {
done func()
mu sync.Mutex
published []beat.Event
cursors []map[string]interface{}
mu sync.Mutex
}

func (p *publisher) Publish(e beat.Event, cursor interface{}) error {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/input/salesforce/soql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ var _ soql.QueryFormatter = (*querier)(nil)

func TestFormat(t *testing.T) {
tests := map[string]struct {
wantErr error
input string
wantStr string
wantErr error
}{
"empty query": {input: "", wantStr: "", wantErr: errors.New("query is empty")},
"valid query": {input: "SELECT FIELDS(STANDARD) FROM LoginEvent", wantStr: "SELECT FIELDS(STANDARD) FROM LoginEvent", wantErr: nil},
Expand Down

0 comments on commit 16d8c31

Please sign in to comment.