botsession

package
v0.0.0-...-8ff35f7 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package botsession implements marshaling of Bot Session protos.

Index

Constants

View Source
const Expiry = time.Hour

Expiry is how long a new Swarming session token will last.

Variables

This section is empty.

Functions

func Create

func Create(params SessionParameters) *internalspb.Session

Create initializes a new Session proto for an authorized connecting bot.

Assumes all parameters have been validated already.

func DebugInfo

func DebugInfo(ctx context.Context, backendVer string) *internalspb.DebugInfo

DebugInfo generates new DebugInfo proto identifying the current request.

func FormatForDebug

func FormatForDebug(s *internalspb.Session) string

FormatForDebug formats the session proto for the debug log.

func Marshal

func Marshal(s *internalspb.Session, secret *hmactoken.Secret) ([]byte, error)

Marshal serializes and signs a bot session proto.

func Unmarshal

func Unmarshal(tok []byte, secret *hmactoken.Secret) (*internalspb.Session, error)

Unmarshal checks the signature and deserializes a bot session.

Doesn't check expiration time or validity of any Session fields.

Types

type SessionParameters

type SessionParameters struct {
	// SessionID is the new session's ID as reported by the bot.
	SessionID string
	// BotID is the bot ID as reported by the bot.
	BotID string
	// BotGroup is the matching bot group config as looked up from bots.cfg.
	BotGroup *cfg.BotGroup
	// RBEConfig is the matching bot RBE config as looked up from pools.cfg.
	RBEConfig cfg.RBEConfig
	// ServerConfig is the config instance used to look up BotGroup and RBEConfig.
	ServerConfig *cfg.Config
	// DebugInfo to put into the session proto.
	DebugInfo *internalspb.DebugInfo
	// Now is the current time to use to calculate the expiration timestamp.
	Now time.Time
}

SessionParameters encapsulates arguments of Create function.

Jump to

Keyboard shortcuts

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