internal

package
v0.0.0-...-3918530 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SpannerString = func(s spanner.NullString) string {
		switch {
		case !s.IsNull():
			return s.String()
		default:
			return ""
		}
	}
)

Functions

func GetSnapshot

func GetSnapshot(object string) ([]byte, error)

func GetSpannerCurrentTime

func GetSpannerCurrentTime(client *spanner.Client) time.Time

func LockTimeDiff

func LockTimeDiff(client *spanner.Client, start string, duration int64) (int64, error)

LockTimeDiff returns the difference between lock's start time + duration against Spanner's current time. Negative means already expired, else still active.

func NewEvent

func NewEvent(data interface{}, args ...string) cloudevents.Event

newEvent returns a JSON (by default) standard cloudevent. Optional arguments: args[0] = source (string) args[1] = type (string) args[2] = contenttype (string), default: application/json See https://github.com/cloudevents/sdk-go for more details.

func PutSnapshot

func PutSnapshot(object string, data []byte) error

func QuerySpannerSingle

func QuerySpannerSingle(ctx context.Context, in *QuerySpannerSingleInput, opts ...option.ClientOption) ([]*spanner.Row, error)

QuerySpannerSingle is a helper function that does simple Spanner db queries. You can override the client object. It will use the Single() transaction from the client by default. If no option for auth is provided, it will authenticate using the GOOGLE_APPLICATION_CREDENTIALS environment variable.

When a client is provided, it will use the client without calling Close() and ignores the opts array. Otherwise, it will create a local client from the 'Database' string together with the opts array.

func StringToBytes

func StringToBytes(s string) []byte

func TraceSlack

func TraceSlack(payload, title string, args ...string)

Optional 'args': [0] - color: good, warning, danger [1..] - channel(s) override

Types

type QuerySpannerSingleInput

type QuerySpannerSingleInput struct {
	Client   *spanner.Client
	Database string
	Query    string
	Params   map[string]interface{} // if provided, assumed that Query has params
}

type SlackAttachment

type SlackAttachment struct {
	// Fallback is our simple fallback text equivalent.
	Fallback string `json:"fallback"`

	// Color can be 'good', 'warning', 'danger', or any hex color code.
	Color string `json:"color,omitempty"`

	// Pretext is our text above the attachment section.
	Pretext string `json:"pretext,omitempty"`

	// Title is the notification title.
	Title string `json:"title,omitempty"`

	// TitleLink is the url link attached to the title.
	TitleLink string `json:"title_link,omitempty"`

	// Text is the main text in the attachment.
	Text string `json:"text"`

	// Footer is a brief text to help contextualize and identify an attachment.
	// Limited to 300 characters, and may be truncated further when displayed
	// to users in environments with limited screen real estate.
	Footer string `json:"footer,omitempty"`

	// Timestamp is an integer Unix timestamp that is used to related your attachment to
	// a specific time. The attachment will display the additional timestamp value as part
	// of the attachment's footer.
	Timestamp int64 `json:"ts,omitempty"`
}

type SlackNotify

type SlackNotify struct {
	Attachments []SlackAttachment `json:"attachments"`
}

func (*SlackNotify) SimpleNotify

func (sn *SlackNotify) SimpleNotify(slackUrl string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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