refactor: going from protobuf to go structs since sessions and their related data are not oplogged

jimlambrt-session-basics
Jim Lambert 6 years ago
parent 4262f16fe5
commit e115808897

@ -1,82 +0,0 @@
syntax = "proto3";
package controller.storage.session.store.v1;
option go_package = "github.com/hashicorp/boundary/internal/session/store;store";
import "controller/storage/timestamp/v1/timestamp.proto";
import "controller/custom_options/v1/options.proto";
message Session {
// public is used to access the session via an API
// @inject_tag: gorm:"primary_key"
string public_id = 10;
// user_id for the session
// @inject_tag: `gorm:"default:null"`
string user_id = 20;
// host_id of the session
// @inject_tag: `gorm:"default:null"`
string host_id = 30;
// server_id that proxied the session
// @inject_tag: `gorm:"default:null"`
string server_id = 40;
// server_type that proxied the session
// @inject_tag: `gorm:"default:null"`
string server_type = 50;
// @inject_tag: `gorm:"default:null"`
string target_id = 60;
// set_id for the session
// @inject_tag: `gorm:"default:null"`
string set_id = 70;
// auth_token_id for the session
// @inject_tag: `gorm:"default:null"`
string auth_token_id = 80;
// scope id for the session
// @inject_tag: `gorm:"default:null"`
string scope_id = 90;
// termination_reason for the session
// @inject_tag: `gorm:"default:null"`
string termination_reason = 100;
// create_time from the RDBMS
// @inject_tag: `gorm:"default:current_timestamp"`
timestamp.v1.Timestamp create_time = 150;
// update_time from the RDBMS
// @inject_tag: `gorm:"default:current_timestamp"`
timestamp.v1.Timestamp update_time = 160;
// version for the session
// @inject_tag: `gorm:"default:null"`
uint32 version = 170;
}
message State {
// session_id references the session public id
// @inject_tag: gorm:"primary_key"
string session_id = 10;
// status of the session
// @inject_tag: gorm:"column:state"
string status = 20;
// previous_end_time from the RDBMS
// @inject_tag: `gorm:"default:current_timestamp"`
timestamp.v1.Timestamp previous_end_time = 30;
// start_time from the RDBMS
// @inject_tag: `gorm:"default:current_timestamp;primary_key"`
timestamp.v1.Timestamp start_time = 40;
// end_time from the RDBMS
// @inject_tag: `gorm:"default:current_timestamp"`
timestamp.v1.Timestamp end_time = 50;
}

@ -9,7 +9,6 @@ import (
"github.com/hashicorp/boundary/internal/iam"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/timestamppb"
)
@ -65,7 +64,7 @@ func TestSession_ImmutableFields(t *testing.T) {
err = rw.LookupById(context.Background(), after)
require.NoError(err)
assert.True(proto.Equal(orig.(*Session), after.(*Session)))
assert.Equal(orig.(*Session), after)
})
}
@ -136,7 +135,7 @@ func TestState_ImmutableFields(t *testing.T) {
after := new.Clone()
err = rw.LookupWhere(context.Background(), after, "session_id = ? and start_time = ?", new.SessionId, new.StartTime)
require.NoError(err)
assert.True(proto.Equal(orig.(*State), after.(*State)))
assert.Equal(orig.(*State), after)
})
}
}

@ -59,9 +59,6 @@ func (r *Repository) CreateSession(ctx context.Context, newSession *Session, opt
if newSession == nil {
return nil, nil, fmt.Errorf("create session: missing session: %w", db.ErrInvalidParameter)
}
if newSession.Session == nil {
return nil, nil, fmt.Errorf("create session: missing session store: %w", db.ErrInvalidParameter)
}
if newSession.PublicId != "" {
return nil, nil, fmt.Errorf("create session: public id is not empty: %w", db.ErrInvalidParameter)
}
@ -226,9 +223,6 @@ func (r *Repository) UpdateSession(ctx context.Context, session *Session, versio
if session == nil {
return nil, nil, db.NoRowsAffected, fmt.Errorf("update session: missing session %w", db.ErrInvalidParameter)
}
if session.Session == nil {
return nil, nil, db.NoRowsAffected, fmt.Errorf("update session: missing session store %w", db.ErrInvalidParameter)
}
if session.PublicId == "" {
return nil, nil, db.NoRowsAffected, fmt.Errorf("update session: missing session public id %w", db.ErrInvalidParameter)
}

@ -16,12 +16,10 @@ import (
"github.com/hashicorp/boundary/internal/kms"
"github.com/hashicorp/boundary/internal/oplog"
"github.com/hashicorp/boundary/internal/servers"
"github.com/hashicorp/boundary/internal/session/store"
"github.com/hashicorp/boundary/internal/target"
"github.com/hashicorp/go-uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
)
func TestNewRepository(t *testing.T) {
@ -185,9 +183,9 @@ func TestRepository_ListSession(t *testing.T) {
assert.Equal(wantCnt, len(got))
for i := 0; i < len(got)-1; i++ {
first, err := ptypes.Timestamp(got[i].GetCreateTime().Timestamp)
first, err := ptypes.Timestamp(got[i].CreateTime.Timestamp)
require.NoError(err)
second, err := ptypes.Timestamp(got[i+1].GetCreateTime().Timestamp)
second, err := ptypes.Timestamp(got[i+1].CreateTime.Timestamp)
require.NoError(err)
assert.True(first.Before(second))
}
@ -310,14 +308,12 @@ func TestRepository_CreateSession(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
s := &Session{
Session: &store.Session{
UserId: tt.args.composedOf.UserId,
HostId: tt.args.composedOf.HostId,
TargetId: tt.args.composedOf.TargetId,
SetId: tt.args.composedOf.HostSetId,
AuthTokenId: tt.args.composedOf.AuthTokenId,
ScopeId: tt.args.composedOf.ScopeId,
},
UserId: tt.args.composedOf.UserId,
HostId: tt.args.composedOf.HostId,
TargetId: tt.args.composedOf.TargetId,
SetId: tt.args.composedOf.HostSetId,
AuthTokenId: tt.args.composedOf.AuthTokenId,
ScopeId: tt.args.composedOf.ScopeId,
}
ses, st, err := repo.CreateSession(context.Background(), s)
if tt.wantErr {
@ -332,16 +328,16 @@ func TestRepository_CreateSession(t *testing.T) {
require.NoError(err)
assert.NotNil(ses.CreateTime)
assert.NotNil(st.StartTime)
assert.Equal(st.GetStatus(), StatusPending.String())
assert.Equal(st.Status, StatusPending.String())
foundSession, foundStates, err := repo.LookupSession(context.Background(), ses.PublicId)
assert.NoError(err)
assert.True(proto.Equal(foundSession, ses))
assert.Equal(foundSession, ses)
err = db.TestVerifyOplog(t, rw, ses.PublicId, db.WithOperation(oplog.OpType_OP_TYPE_CREATE), db.WithCreateNotBefore(10*time.Second))
assert.Error(err)
require.Equal(1, len(foundStates))
assert.Equal(foundStates[0].GetStatus(), StatusPending.String())
assert.Equal(foundStates[0].Status, StatusPending.String())
})
}
}
@ -672,7 +668,7 @@ func TestRepository_UpdateSession(t *testing.T) {
}
foundSession, foundStates, err := repo.LookupSession(context.Background(), s.PublicId)
require.NoError(err)
assert.True(proto.Equal(afterUpdateSession, foundSession))
assert.Equal(afterUpdateSession, foundSession)
dbassrt := dbassert.New(t, rw)
if tt.args.serverId == "" {
dbassrt.IsNull(foundSession, "ServerId")

@ -6,8 +6,8 @@ import (
"strings"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/session/store"
"google.golang.org/protobuf/proto"
"github.com/hashicorp/boundary/internal/db/timestamp"
"google.golang.org/protobuf/types/known/timestamppb"
)
const (
@ -32,10 +32,40 @@ type ComposedOf struct {
// Session contains information about a user's session with a target
type Session struct {
*store.Session
// PublicId is used to access the session via an API
PublicId string `json:"public_id,omitempty" gorm:"primary_key"`
// UserId for the session
UserId string `json:"user_id,omitempty" gorm:"default:null"`
// HostId of the session
HostId string `json:"host_id,omitempty" gorm:"default:null"`
// ServerId that proxied the session
ServerId string `json:"server_id,omitempty" gorm:"default:null"`
// ServerType that proxied the session
ServerType string `json:"server_type,omitempty" gorm:"default:null"`
// TargetId for the session
TargetId string `json:"target_id,omitempty" gorm:"default:null"`
// SetId for the session
SetId string `json:"set_id,omitempty" gorm:"default:null"`
// AuthTokenId for the session
AuthTokenId string `json:"auth_token_id,omitempty" gorm:"default:null"`
// ScopeId for the session
ScopeId string `json:"scope_id,omitempty" gorm:"default:null"`
// termination_reason for the session
TerminationReason string `json:"termination_reason,omitempty" gorm:"default:null"`
// CreateTime from the RDBMS
CreateTime *timestamp.Timestamp `json:"create_time,omitempty" gorm:"default:current_timestamp"`
// UpdateTime from the RDBMS
UpdateTime *timestamp.Timestamp `json:"update_time,omitempty" gorm:"default:current_timestamp"`
// Version for the session
Version uint32 `json:"version,omitempty" gorm:"default:null"`
tableName string `gorm:"-"`
}
func (s *Session) GetPublicId() string {
return s.PublicId
}
var _ Cloneable = (*Session)(nil)
var _ db.VetForWriter = (*Session)(nil)
@ -43,14 +73,12 @@ var _ db.VetForWriter = (*Session)(nil)
// are currently supported.
func New(c ComposedOf, opt ...Option) (*Session, error) {
s := Session{
Session: &store.Session{
UserId: c.UserId,
HostId: c.HostId,
TargetId: c.TargetId,
SetId: c.HostSetId,
AuthTokenId: c.AuthTokenId,
ScopeId: c.ScopeId,
},
UserId: c.UserId,
HostId: c.HostId,
TargetId: c.TargetId,
SetId: c.HostSetId,
AuthTokenId: c.AuthTokenId,
ScopeId: c.ScopeId,
}
if err := s.validateNewSession("new session:"); err != nil {
@ -61,17 +89,41 @@ func New(c ComposedOf, opt ...Option) (*Session, error) {
// AllocSession will allocate a Session
func AllocSession() Session {
return Session{
Session: &store.Session{},
}
return Session{}
}
// Clone creates a clone of the Session
func (s *Session) Clone() interface{} {
cp := proto.Clone(s.Session)
return &Session{
Session: cp.(*store.Session),
clone := &Session{
PublicId: s.PublicId,
UserId: s.UserId,
HostId: s.HostId,
ServerId: s.ServerId,
ServerType: s.ServerType,
TargetId: s.TargetId,
SetId: s.SetId,
AuthTokenId: s.AuthTokenId,
ScopeId: s.ScopeId,
TerminationReason: s.TerminationReason,
Version: s.Version,
}
if s.CreateTime != nil {
clone.CreateTime = &timestamp.Timestamp{
Timestamp: &timestamppb.Timestamp{
Seconds: s.CreateTime.Timestamp.Seconds,
Nanos: s.CreateTime.Timestamp.Nanos,
},
}
}
if s.UpdateTime != nil {
clone.UpdateTime = &timestamp.Timestamp{
Timestamp: &timestamppb.Timestamp{
Seconds: s.UpdateTime.Timestamp.Seconds,
Nanos: s.UpdateTime.Timestamp.Nanos,
},
}
}
return clone
}
// VetForWrite implements db.VetForWrite() interface and validates the session

@ -7,10 +7,8 @@ import (
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/session/store"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
)
func TestSession_Create(t *testing.T) {
@ -39,14 +37,12 @@ func TestSession_Create(t *testing.T) {
composedOf: composedOf,
},
want: &Session{
Session: &store.Session{
UserId: composedOf.UserId,
HostId: composedOf.HostId,
TargetId: composedOf.TargetId,
SetId: composedOf.HostSetId,
AuthTokenId: composedOf.AuthTokenId,
ScopeId: composedOf.ScopeId,
},
UserId: composedOf.UserId,
HostId: composedOf.HostId,
TargetId: composedOf.TargetId,
SetId: composedOf.HostSetId,
AuthTokenId: composedOf.AuthTokenId,
ScopeId: composedOf.ScopeId,
},
create: true,
},
@ -217,7 +213,7 @@ func TestSession_Clone(t *testing.T) {
assert := assert.New(t)
s := TestDefaultSession(t, conn, wrapper, iamRepo)
cp := s.Clone()
assert.True(proto.Equal(cp.(*Session).Session, s.Session))
assert.Equal(cp.(*Session), s)
})
t.Run("not-equal", func(t *testing.T) {
assert := assert.New(t)
@ -225,7 +221,7 @@ func TestSession_Clone(t *testing.T) {
s2 := TestDefaultSession(t, conn, wrapper, iamRepo)
cp := s.Clone()
assert.True(!proto.Equal(cp.(*Session).Session, s2.Session))
assert.NotEqual(cp.(*Session), s2)
})
}

@ -5,8 +5,8 @@ import (
"fmt"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/session/store"
"google.golang.org/protobuf/proto"
"github.com/hashicorp/boundary/internal/db/timestamp"
"google.golang.org/protobuf/types/known/timestamppb"
)
const (
@ -30,7 +30,17 @@ func (s Status) String() string {
// State of the session
type State struct {
*store.State
// SessionId references the session public id
SessionId string `json:"session_id,omitempty" gorm:"primary_key"`
// status of the session
Status string `json:"status,omitempty" gorm:"column:state"`
// PreviousEndTime from the RDBMS
PreviousEndTime *timestamp.Timestamp `json:"previous_end_time,omitempty" gorm:"default:current_timestamp"`
// StartTime from the RDBMS
StartTime *timestamp.Timestamp `json:"start_time,omitempty" gorm:"default:current_timestamp;primary_key"`
// EndTime from the RDBMS
EndTime *timestamp.Timestamp `json:"end_time,omitempty" gorm:"default:current_timestamp"`
tableName string `gorm:"-"`
}
@ -41,10 +51,8 @@ var _ db.VetForWriter = (*State)(nil)
// are currently supported.
func NewState(session_id string, state Status, opt ...Option) (*State, error) {
s := State{
State: &store.State{
SessionId: session_id,
Status: state.String(),
},
SessionId: session_id,
Status: state.String(),
}
if err := s.validate("new session state:"); err != nil {
@ -55,17 +63,41 @@ func NewState(session_id string, state Status, opt ...Option) (*State, error) {
// allocState will allocate a State
func allocState() State {
return State{
State: &store.State{},
}
return State{}
}
// Clone creates a clone of the State
func (s *State) Clone() interface{} {
cp := proto.Clone(s.State)
return &State{
State: cp.(*store.State),
clone := &State{
SessionId: s.SessionId,
Status: s.Status,
}
if s.PreviousEndTime != nil {
clone.PreviousEndTime = &timestamp.Timestamp{
Timestamp: &timestamppb.Timestamp{
Seconds: s.PreviousEndTime.Timestamp.Seconds,
Nanos: s.PreviousEndTime.Timestamp.Nanos,
},
}
}
if s.StartTime != nil {
clone.StartTime = &timestamp.Timestamp{
Timestamp: &timestamppb.Timestamp{
Seconds: s.StartTime.Timestamp.Seconds,
Nanos: s.StartTime.Timestamp.Nanos,
},
}
}
if s.EndTime != nil {
clone.EndTime = &timestamp.Timestamp{
Timestamp: &timestamppb.Timestamp{
Seconds: s.EndTime.Timestamp.Seconds,
Nanos: s.EndTime.Timestamp.Nanos,
},
}
}
return clone
}
// VetForWrite implements db.VetForWrite() interface and validates the state
@ -94,9 +126,6 @@ func (s *State) SetTableName(n string) {
// validate checks the session state
func (s *State) validate(errorPrefix string) error {
if s.State == nil {
return fmt.Errorf("%s missing state: %w", errorPrefix, db.ErrInvalidParameter)
}
if s.Status == "" {
return fmt.Errorf("%s missing status: %w", errorPrefix, db.ErrInvalidParameter)
}

@ -3,15 +3,12 @@ package session
import (
"context"
"errors"
"fmt"
"testing"
"github.com/hashicorp/boundary/internal/db"
"github.com/hashicorp/boundary/internal/iam"
"github.com/hashicorp/boundary/internal/session/store"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
)
func TestState_Create(t *testing.T) {
@ -41,10 +38,8 @@ func TestState_Create(t *testing.T) {
status: StatusPending,
},
want: &State{
State: &store.State{
SessionId: session.PublicId,
Status: StatusPending.String(),
},
SessionId: session.PublicId,
Status: StatusPending.String(),
},
create: true,
},
@ -152,7 +147,6 @@ func TestState_Delete(t *testing.T) {
assert.Equal(tt.wantRowsDeleted, deletedRows)
foundState := allocState()
err = rw.LookupWhere(context.Background(), &foundState, "session_id = ? and start_time = ?", tt.state.SessionId, initialState.StartTime)
fmt.Println(foundState)
require.Error(err)
assert.True(errors.Is(db.ErrRecordNotFound, err))
})
@ -169,7 +163,7 @@ func TestState_Clone(t *testing.T) {
s := TestDefaultSession(t, conn, wrapper, iamRepo)
state := TestState(t, conn, s.PublicId, StatusPending)
cp := state.Clone()
assert.True(proto.Equal(cp.(*State).State, state.State))
assert.Equal(cp.(*State), state)
})
t.Run("not-equal", func(t *testing.T) {
assert := assert.New(t)
@ -179,7 +173,7 @@ func TestState_Clone(t *testing.T) {
state2 := TestState(t, conn, s2.PublicId, StatusPending)
cp := state.Clone()
assert.True(!proto.Equal(cp.(*State).State, state2.State))
assert.NotEqual(cp.(*State), state2)
})
}

@ -1,438 +0,0 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.4
// source: controller/storage/session/store/v1/session.proto
package store
import (
proto "github.com/golang/protobuf/proto"
timestamp "github.com/hashicorp/boundary/internal/db/timestamp"
_ "github.com/hashicorp/boundary/internal/gen/controller/protooptions"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type Session struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// public is used to access the session via an API
// @inject_tag: gorm:"primary_key"
PublicId string `protobuf:"bytes,10,opt,name=public_id,json=publicId,proto3" json:"public_id,omitempty" gorm:"primary_key"`
// user_id for the session
// @inject_tag: `gorm:"default:null"`
UserId string `protobuf:"bytes,20,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty" gorm:"default:null"`
// host_id of the session
// @inject_tag: `gorm:"default:null"`
HostId string `protobuf:"bytes,30,opt,name=host_id,json=hostId,proto3" json:"host_id,omitempty" gorm:"default:null"`
// server_id that proxied the session
// @inject_tag: `gorm:"default:null"`
ServerId string `protobuf:"bytes,40,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty" gorm:"default:null"`
// server_type that proxied the session
// @inject_tag: `gorm:"default:null"`
ServerType string `protobuf:"bytes,50,opt,name=server_type,json=serverType,proto3" json:"server_type,omitempty" gorm:"default:null"`
// @inject_tag: `gorm:"default:null"`
TargetId string `protobuf:"bytes,60,opt,name=target_id,json=targetId,proto3" json:"target_id,omitempty" gorm:"default:null"`
// set_id for the session
// @inject_tag: `gorm:"default:null"`
SetId string `protobuf:"bytes,70,opt,name=set_id,json=setId,proto3" json:"set_id,omitempty" gorm:"default:null"`
// auth_token_id for the session
// @inject_tag: `gorm:"default:null"`
AuthTokenId string `protobuf:"bytes,80,opt,name=auth_token_id,json=authTokenId,proto3" json:"auth_token_id,omitempty" gorm:"default:null"`
// scope id for the session
// @inject_tag: `gorm:"default:null"`
ScopeId string `protobuf:"bytes,90,opt,name=scope_id,json=scopeId,proto3" json:"scope_id,omitempty" gorm:"default:null"`
// termination_reason for the session
// @inject_tag: `gorm:"default:null"`
TerminationReason string `protobuf:"bytes,100,opt,name=termination_reason,json=terminationReason,proto3" json:"termination_reason,omitempty" gorm:"default:null"`
// create_time from the RDBMS
// @inject_tag: `gorm:"default:current_timestamp"`
CreateTime *timestamp.Timestamp `protobuf:"bytes,150,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty" gorm:"default:current_timestamp"`
// update_time from the RDBMS
// @inject_tag: `gorm:"default:current_timestamp"`
UpdateTime *timestamp.Timestamp `protobuf:"bytes,160,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty" gorm:"default:current_timestamp"`
// version for the session
// @inject_tag: `gorm:"default:null"`
Version uint32 `protobuf:"varint,170,opt,name=version,proto3" json:"version,omitempty" gorm:"default:null"`
}
func (x *Session) Reset() {
*x = Session{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_storage_session_store_v1_session_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Session) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Session) ProtoMessage() {}
func (x *Session) ProtoReflect() protoreflect.Message {
mi := &file_controller_storage_session_store_v1_session_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Session.ProtoReflect.Descriptor instead.
func (*Session) Descriptor() ([]byte, []int) {
return file_controller_storage_session_store_v1_session_proto_rawDescGZIP(), []int{0}
}
func (x *Session) GetPublicId() string {
if x != nil {
return x.PublicId
}
return ""
}
func (x *Session) GetUserId() string {
if x != nil {
return x.UserId
}
return ""
}
func (x *Session) GetHostId() string {
if x != nil {
return x.HostId
}
return ""
}
func (x *Session) GetServerId() string {
if x != nil {
return x.ServerId
}
return ""
}
func (x *Session) GetServerType() string {
if x != nil {
return x.ServerType
}
return ""
}
func (x *Session) GetTargetId() string {
if x != nil {
return x.TargetId
}
return ""
}
func (x *Session) GetSetId() string {
if x != nil {
return x.SetId
}
return ""
}
func (x *Session) GetAuthTokenId() string {
if x != nil {
return x.AuthTokenId
}
return ""
}
func (x *Session) GetScopeId() string {
if x != nil {
return x.ScopeId
}
return ""
}
func (x *Session) GetTerminationReason() string {
if x != nil {
return x.TerminationReason
}
return ""
}
func (x *Session) GetCreateTime() *timestamp.Timestamp {
if x != nil {
return x.CreateTime
}
return nil
}
func (x *Session) GetUpdateTime() *timestamp.Timestamp {
if x != nil {
return x.UpdateTime
}
return nil
}
func (x *Session) GetVersion() uint32 {
if x != nil {
return x.Version
}
return 0
}
type State struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// session_id references the session public id
// @inject_tag: gorm:"primary_key"
SessionId string `protobuf:"bytes,10,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty" gorm:"primary_key"`
// status of the session
// @inject_tag: gorm:"column:state"
Status string `protobuf:"bytes,20,opt,name=status,proto3" json:"status,omitempty" gorm:"column:state"`
// previous_end_time from the RDBMS
// @inject_tag: `gorm:"default:current_timestamp"`
PreviousEndTime *timestamp.Timestamp `protobuf:"bytes,30,opt,name=previous_end_time,json=previousEndTime,proto3" json:"previous_end_time,omitempty" gorm:"default:current_timestamp"`
// start_time from the RDBMS
// @inject_tag: `gorm:"default:current_timestamp;primary_key"`
StartTime *timestamp.Timestamp `protobuf:"bytes,40,opt,name=start_time,json=startTime,proto3" json:"start_time,omitempty" gorm:"default:current_timestamp;primary_key"`
// end_time from the RDBMS
// @inject_tag: `gorm:"default:current_timestamp"`
EndTime *timestamp.Timestamp `protobuf:"bytes,50,opt,name=end_time,json=endTime,proto3" json:"end_time,omitempty" gorm:"default:current_timestamp"`
}
func (x *State) Reset() {
*x = State{}
if protoimpl.UnsafeEnabled {
mi := &file_controller_storage_session_store_v1_session_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *State) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*State) ProtoMessage() {}
func (x *State) ProtoReflect() protoreflect.Message {
mi := &file_controller_storage_session_store_v1_session_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use State.ProtoReflect.Descriptor instead.
func (*State) Descriptor() ([]byte, []int) {
return file_controller_storage_session_store_v1_session_proto_rawDescGZIP(), []int{1}
}
func (x *State) GetSessionId() string {
if x != nil {
return x.SessionId
}
return ""
}
func (x *State) GetStatus() string {
if x != nil {
return x.Status
}
return ""
}
func (x *State) GetPreviousEndTime() *timestamp.Timestamp {
if x != nil {
return x.PreviousEndTime
}
return nil
}
func (x *State) GetStartTime() *timestamp.Timestamp {
if x != nil {
return x.StartTime
}
return nil
}
func (x *State) GetEndTime() *timestamp.Timestamp {
if x != nil {
return x.EndTime
}
return nil
}
var File_controller_storage_session_store_v1_session_proto protoreflect.FileDescriptor
var file_controller_storage_session_store_v1_session_proto_rawDesc = []byte{
0x0a, 0x31, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x73, 0x74, 0x6f,
0x72, 0x61, 0x67, 0x65, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x74, 0x6f,
0x72, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x12, 0x23, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e,
0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x2e,
0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f,
0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x74, 0x69, 0x6d,
0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x63, 0x6f, 0x6e, 0x74, 0x72,
0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2f, 0x63, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x5f, 0x6f, 0x70, 0x74,
0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x76, 0x31, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xef, 0x03, 0x0a, 0x07, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x69, 0x64, 0x18, 0x0a,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x49, 0x64, 0x12, 0x17,
0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x68, 0x6f, 0x73, 0x74, 0x5f,
0x69, 0x64, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x68, 0x6f, 0x73, 0x74, 0x49, 0x64,
0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x28, 0x20,
0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a,
0x0b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x32, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1b,
0x0a, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x3c, 0x20, 0x01, 0x28,
0x09, 0x52, 0x08, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x49, 0x64, 0x12, 0x15, 0x0a, 0x06, 0x73,
0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x46, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x65, 0x74,
0x49, 0x64, 0x12, 0x22, 0x0a, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e,
0x5f, 0x69, 0x64, 0x18, 0x50, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x75, 0x74, 0x68, 0x54,
0x6f, 0x6b, 0x65, 0x6e, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x5f,
0x69, 0x64, 0x18, 0x5a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x49,
0x64, 0x12, 0x2d, 0x0a, 0x12, 0x74, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x5f, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x18, 0x64, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x74,
0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x61, 0x73, 0x6f, 0x6e,
0x12, 0x4c, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18,
0x96, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65,
0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
0x6d, 0x70, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x4c,
0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0xa0, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65,
0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70,
0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x07,
0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0xaa, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x07,
0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xa8, 0x02, 0x0a, 0x05, 0x53, 0x74, 0x61, 0x74,
0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18,
0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x64,
0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09,
0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x56, 0x0a, 0x11, 0x70, 0x72, 0x65, 0x76,
0x69, 0x6f, 0x75, 0x73, 0x5f, 0x65, 0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x1e, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72,
0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61,
0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52,
0x0f, 0x70, 0x72, 0x65, 0x76, 0x69, 0x6f, 0x75, 0x73, 0x45, 0x6e, 0x64, 0x54, 0x69, 0x6d, 0x65,
0x12, 0x49, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x28,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65,
0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74,
0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70,
0x52, 0x09, 0x73, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x45, 0x0a, 0x08, 0x65,
0x6e, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x32, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x2e,
0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x61,
0x67, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x76, 0x31, 0x2e,
0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x07, 0x65, 0x6e, 0x64, 0x54, 0x69,
0x6d, 0x65, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x68, 0x61, 0x73, 0x68, 0x69, 0x63, 0x6f, 0x72, 0x70, 0x2f, 0x62, 0x6f, 0x75, 0x6e, 0x64,
0x61, 0x72, 0x79, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x73, 0x65, 0x73,
0x73, 0x69, 0x6f, 0x6e, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_controller_storage_session_store_v1_session_proto_rawDescOnce sync.Once
file_controller_storage_session_store_v1_session_proto_rawDescData = file_controller_storage_session_store_v1_session_proto_rawDesc
)
func file_controller_storage_session_store_v1_session_proto_rawDescGZIP() []byte {
file_controller_storage_session_store_v1_session_proto_rawDescOnce.Do(func() {
file_controller_storage_session_store_v1_session_proto_rawDescData = protoimpl.X.CompressGZIP(file_controller_storage_session_store_v1_session_proto_rawDescData)
})
return file_controller_storage_session_store_v1_session_proto_rawDescData
}
var file_controller_storage_session_store_v1_session_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_controller_storage_session_store_v1_session_proto_goTypes = []interface{}{
(*Session)(nil), // 0: controller.storage.session.store.v1.Session
(*State)(nil), // 1: controller.storage.session.store.v1.State
(*timestamp.Timestamp)(nil), // 2: controller.storage.timestamp.v1.Timestamp
}
var file_controller_storage_session_store_v1_session_proto_depIdxs = []int32{
2, // 0: controller.storage.session.store.v1.Session.create_time:type_name -> controller.storage.timestamp.v1.Timestamp
2, // 1: controller.storage.session.store.v1.Session.update_time:type_name -> controller.storage.timestamp.v1.Timestamp
2, // 2: controller.storage.session.store.v1.State.previous_end_time:type_name -> controller.storage.timestamp.v1.Timestamp
2, // 3: controller.storage.session.store.v1.State.start_time:type_name -> controller.storage.timestamp.v1.Timestamp
2, // 4: controller.storage.session.store.v1.State.end_time:type_name -> controller.storage.timestamp.v1.Timestamp
5, // [5:5] is the sub-list for method output_type
5, // [5:5] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { file_controller_storage_session_store_v1_session_proto_init() }
func file_controller_storage_session_store_v1_session_proto_init() {
if File_controller_storage_session_store_v1_session_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_controller_storage_session_store_v1_session_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Session); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_controller_storage_session_store_v1_session_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*State); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_controller_storage_session_store_v1_session_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_controller_storage_session_store_v1_session_proto_goTypes,
DependencyIndexes: file_controller_storage_session_store_v1_session_proto_depIdxs,
MessageInfos: file_controller_storage_session_store_v1_session_proto_msgTypes,
}.Build()
File_controller_storage_session_store_v1_session_proto = out.File
file_controller_storage_session_store_v1_session_proto_rawDesc = nil
file_controller_storage_session_store_v1_session_proto_goTypes = nil
file_controller_storage_session_store_v1_session_proto_depIdxs = nil
}
Loading…
Cancel
Save