...

Source file src/golang.conradwood.net/go-easyops/ctx/ctxv2/localstate.go

Documentation: golang.conradwood.net/go-easyops/ctx/ctxv2

     1  package ctxv2
     2  
     3  import (
     4  	"golang.conradwood.net/apis/auth"
     5  	ge "golang.conradwood.net/apis/goeasyops"
     6  	"golang.conradwood.net/go-easyops/ctx/shared"
     7  	"golang.yacloud.eu/apis/session"
     8  )
     9  
    10  type localState struct {
    11  	this_is_v2_local_state string
    12  	builder                *contextBuilder
    13  	callingservice         *auth.SignedUser // who called us (different from contextbuilder, which contains this service's id)
    14  }
    15  
    16  // this function only serves to assert that localState satisfies its interface (compile-error otherwise)
    17  func assert_localstate_interface() shared.LocalState {
    18  	return &localState{this_is_v2_local_state: "v2_localstate"}
    19  }
    20  func (ls *localState) CreatorService() *auth.SignedUser {
    21  	if ls == nil || ls.builder == nil {
    22  		return nil
    23  	}
    24  	return ls.builder.ge_context.ImCtx.CreatorService
    25  }
    26  func (ls *localState) CallingService() *auth.SignedUser {
    27  	if ls == nil {
    28  		return nil
    29  	}
    30  	return ls.callingservice
    31  	//	return ls.builder.ge_context.MCtx.CallingService // NOTE: this is always 'us' (the service we are running at, because the inbound2outbound makes it so)
    32  }
    33  func (ls *localState) Info() string {
    34  	if ls.builder == nil {
    35  		return "nobuilder"
    36  	}
    37  	return "localstate_from_ctxv2_builder"
    38  }
    39  func (ls *localState) Experiments() []*ge.Experiment {
    40  	if ls == nil || ls.builder == nil {
    41  		return nil
    42  	}
    43  	return ls.builder.ge_context.MCtx.Experiments
    44  }
    45  func (ls *localState) Debug() bool {
    46  	if ls == nil || ls.builder == nil {
    47  		return false
    48  	}
    49  	return ls.builder.ge_context.MCtx.Debug
    50  }
    51  func (ls *localState) Trace() bool {
    52  	if ls == nil || ls.builder == nil {
    53  		return false
    54  	}
    55  	return ls.builder.ge_context.MCtx.Trace
    56  }
    57  func (ls *localState) User() *auth.SignedUser {
    58  	return ls.builder.ge_context.ImCtx.User
    59  }
    60  func (ls *localState) SudoUser() *auth.SignedUser {
    61  	return ls.builder.ge_context.ImCtx.SudoUser
    62  }
    63  func (ls *localState) Session() *session.Session {
    64  	if ls == nil {
    65  		return nil
    66  	}
    67  	return ls.builder.ge_context.ImCtx.Session
    68  }
    69  func (ls *localState) RequestID() string {
    70  	return ls.builder.ge_context.ImCtx.RequestID
    71  }
    72  func (ls *localState) RoutingTags() *ge.CTXRoutingTags {
    73  	if ls == nil {
    74  		return nil
    75  	}
    76  	return ls.builder.ge_context.MCtx.Tags
    77  }
    78  func (ls *localState) Services() []*ge.ServiceTrace {
    79  	return ls.builder.ge_context.MCtx.Services
    80  }
    81  func (ls *localState) AuthTags() []string {
    82  	return ls.builder.ge_context.ImCtx.AuthTags
    83  }
    84  

View as plain text