github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/pkg/steampipeconfig/postgres_notification.go (about) 1 package steampipeconfig 2 3 import ( 4 "github.com/turbot/steampipe/pkg/error_helpers" 5 ) 6 7 const PostgresNotificationStructVersion = 20230306 8 9 type PostgresNotificationType int 10 11 const ( 12 PgNotificationSchemaUpdate PostgresNotificationType = iota + 1 13 PgNotificationConnectionError 14 ) 15 16 type PostgresNotification struct { 17 StructVersion int 18 Type PostgresNotificationType 19 } 20 21 type ErrorsAndWarningsNotification struct { 22 PostgresNotification 23 Errors []string 24 Warnings []string 25 } 26 27 func NewSchemaUpdateNotification() *PostgresNotification { 28 return &PostgresNotification{ 29 StructVersion: PostgresNotificationStructVersion, 30 Type: PgNotificationSchemaUpdate, 31 } 32 } 33 34 func NewErrorsAndWarningsNotification(errorAndWarnings error_helpers.ErrorAndWarnings) *ErrorsAndWarningsNotification { 35 res := &ErrorsAndWarningsNotification{ 36 PostgresNotification: PostgresNotification{ 37 StructVersion: PostgresNotificationStructVersion, 38 Type: PgNotificationConnectionError, 39 }, 40 } 41 42 if errorAndWarnings.Error != nil { 43 res.Errors = []string{errorAndWarnings.Error.Error()} 44 } 45 res.Warnings = append(res.Warnings, errorAndWarnings.Warnings...) 46 return res 47 }