session

package
v1.0.1-0...-1811ebb Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package web defines web APIs to be used with harbourbridge frontend. Apart from schema conversion, this package involves API to update converted schema.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConv

func GetConv(w http.ResponseWriter, r *http.Request)

func GetSessions

func GetSessions(w http.ResponseWriter, r *http.Request)

func IsOfflineSession

func IsOfflineSession(w http.ResponseWriter, r *http.Request)

func NewLocalSessionStore

func NewLocalSessionStore() *localStore

func ReadSessionFileForSessionMetadata

func ReadSessionFileForSessionMetadata(metadata *SessionMetadata, sessionJSON string) error

func ResumeSession

func ResumeSession(w http.ResponseWriter, r *http.Request)

func SaveRemoteSession

func SaveRemoteSession(w http.ResponseWriter, r *http.Request)

func SetSessionStorageConnectionState

func SetSessionStorageConnectionState(projectId string, spInstanceId string) (bool, bool)

func UpdateSessionFile

func UpdateSessionFile() error

UpdateSessionFile updates the content of session file with latest sessionState.Conv while also dumping schemas and report.

Types

type ConvWithMetadata

type ConvWithMetadata struct {
	SessionMetadata
	internal.Conv
}

type Counter

type Counter struct {
	ObjectId string
}

Counter used to generate id for table, column, Foreignkey and indexes.

type SchemaConversionSession

type SchemaConversionSession struct {
	SessionMetadata
	VersionId              string
	PreviousVersionId      []string
	SchemaChanges          string
	SchemaConversionObject string
	CreateTimestamp        time.Time
}

type SessionMetadata

type SessionMetadata struct {
	SessionName  string
	EditorName   string
	DatabaseType string
	DatabaseName string
	Dialect      string
	Notes        []string
	Tags         []string
}

type SessionNameError

type SessionNameError struct {
	DbName string
	DbType string
}

func (*SessionNameError) Error

func (e *SessionNameError) Error() string

type SessionParams

type SessionParams struct {
	Driver    string `json:"driver"`
	FilePath  string `json:"filePath"`
	DBName    string `json:"dbName"`
	CreatedAt string `json:"createdAt"`
}

session contains the metadata for a session file. A session file is a snapshot of an ongoing HarbourBridge conversion session, and consists of an internal.Conv struct in JSON format.

type SessionService

type SessionService struct {
	// contains filtered or unexported fields
}

func NewSessionService

func NewSessionService(ctx context.Context, store SessionStore) *SessionService

func (*SessionService) GetConvWithMetadata

func (ss *SessionService) GetConvWithMetadata(versionId string) (ConvWithMetadata, error)

func (*SessionService) GetSessionsMetadata

func (ss *SessionService) GetSessionsMetadata() ([]SchemaConversionSession, error)

func (*SessionService) SaveSession

func (ss *SessionService) SaveSession(scs SchemaConversionSession) error

type SessionState

type SessionState struct {
	SourceDB             *sql.DB             // Connection to source database in case of direct connection
	SourceDBConnDetails  SourceDBConnDetails // Connection details for source database
	DbName               string              // Name of source database
	Driver               string              // Name of HarbourBridge driver in use
	Conv                 *internal.Conv      // Current conversion state
	SessionFile          string              // Path to session file
	IsOffline            bool                // True if the connection to remote metadata database is invalid
	GCPProjectID         string
	SpannerInstanceID    string
	Dialect              string
	IsSharded            bool
	TmpDir               string
	ShardedDbConnDetails []profiles.DirectConnectionConfig
	SourceProfileConfig  profiles.SourceProfileConfig
	Region               string
	SpannerDatabaseName  string
	Bucket               string
	RootPath             string
	SessionMetadata      SessionMetadata
	Error                error
	Counter
}

SessionState stores information for the current migration session.

func GetSessionState

func GetSessionState() *SessionState

type SessionStore

type SessionStore interface {
	GetSessionsMetadata(ctx context.Context) ([]SchemaConversionSession, error)
	GetConvWithMetadata(ctx context.Context, versionId string) (ConvWithMetadata, error)
	SaveSession(ctx context.Context, scs SchemaConversionSession) error
	IsSessionNameUnique(ctx context.Context, scs SchemaConversionSession) (bool, error)
}

func NewRemoteSessionStore

func NewRemoteSessionStore(spannerClient *spanner.Client) SessionStore

type SourceDBConnDetails

type SourceDBConnDetails struct {
	Host           string
	Port           string
	User           string
	Password       string
	Path           string
	ConnectionType string
}

Jump to

Keyboard shortcuts

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