Documentation ¶
Index ¶
- Variables
- func GetSnapshot(object string) ([]byte, error)
- func GetSpannerCurrentTime(client *spanner.Client) time.Time
- func LockTimeDiff(client *spanner.Client, start string, duration int64) (int64, error)
- func NewEvent(data interface{}, args ...string) cloudevents.Event
- func PutSnapshot(object string, data []byte) error
- func QuerySpannerSingle(ctx context.Context, in *QuerySpannerSingleInput, opts ...option.ClientOption) ([]*spanner.Row, error)
- func StringToBytes(s string) []byte
- func TraceSlack(payload, title string, args ...string)
- type QuerySpannerSingleInput
- type SlackAttachment
- type SlackNotify
Constants ¶
This section is empty.
Variables ¶
var (
SpannerString = func(s spanner.NullString) string {
switch {
case !s.IsNull():
return s.String()
default:
return ""
}
}
)
Functions ¶
func GetSnapshot ¶
func LockTimeDiff ¶
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 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 TraceSlack ¶
Optional 'args': [0] - color: good, warning, danger [1..] - channel(s) override
Types ¶
type QuerySpannerSingleInput ¶
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"` // 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