github.com/alloyzeus/go-azfl@v0.0.0-20231220071816-9740126a2d07/azcore/operation.go (about)

     1  package azcore
     2  
     3  import "time"
     4  
     5  const (
     6  	ErrOperationNotAllowed = constantErrorDescriptor("operation not allowed")
     7  )
     8  
     9  // OperationInfo holds information about an action.
    10  type OperationInfo[
    11  	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
    12  	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
    13  	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
    14  	SessionSubjectT SessionSubject[
    15  		TerminalIDNumT, TerminalIDT,
    16  		UserIDNumT, UserIDT],
    17  	SessionT Session[
    18  		SessionIDNumT, SessionIDT,
    19  		TerminalIDNumT, TerminalIDT,
    20  		UserIDNumT, UserIDT,
    21  		SessionSubjectT, SessionT],
    22  ] interface {
    23  	// IdempotencyKey returns the idempotency key for this operation.
    24  	IdempotencyKey() ServiceMethodIdempotencyKey
    25  
    26  	// Actor returns the subject who executed the action. Must not be empty
    27  	// in server, might be empty in clients, might be queryable.
    28  	Actor() SessionSubjectT
    29  
    30  	// Session returns the session by the actor to perform the action.
    31  	// Must not be empty in server, might be empty in clients.
    32  	Session() SessionT
    33  
    34  	// DelegationInfo returns the information about the delegation if this
    35  	// action was delegated to other subject or session.
    36  	DelegationInfo() OperationDelegationInfo[
    37  		SessionIDNumT, SessionIDT,
    38  		TerminalIDNumT, TerminalIDT,
    39  		UserIDNumT, UserIDT, SessionSubjectT, SessionT]
    40  
    41  	// Timestamp returns the time when the action made the effect. This should
    42  	// be obtained from the lowest level, e.g., database or file system.
    43  	//
    44  	// An analogy: in ordering process in a restaurant, the
    45  	// timestamp is the time when the cook declared that the food is ready
    46  	// to be served.
    47  	Timestamp() *time.Time
    48  
    49  	// // BeginTime returns the time when the action was initiated.
    50  	// BeginTime() *time.Time
    51  	// // EndTime return the time when the action was ended.
    52  	// EndTime() *time.Time
    53  }
    54  
    55  // OperationDelegationInfo holds information about delegation for an action
    56  // if that action was delegated.
    57  //
    58  //TODO: actual info
    59  type OperationDelegationInfo[
    60  	SessionIDNumT SessionIDNum, SessionIDT SessionID[SessionIDNumT],
    61  	TerminalIDNumT TerminalIDNum, TerminalIDT TerminalID[TerminalIDNumT],
    62  	UserIDNumT UserIDNum, UserIDT UserID[UserIDNumT],
    63  	SessionSubjectT SessionSubject[
    64  		TerminalIDNumT, TerminalIDT,
    65  		UserIDNumT, UserIDT],
    66  	SessionT Session[
    67  		SessionIDNumT, SessionIDT,
    68  		TerminalIDNumT, TerminalIDT,
    69  		UserIDNumT, UserIDT,
    70  		SessionSubjectT, SessionT],
    71  ] interface {
    72  	// ParentDelegationInfo returns the delegation parent of this delegation.
    73  	ParentDelegationInfo() OperationDelegationInfo[
    74  		SessionIDNumT, SessionIDT,
    75  		TerminalIDNumT, TerminalIDT,
    76  		UserIDNumT, UserIDT, SessionSubjectT, SessionT]
    77  
    78  	// Actor returns the subject who delegated the action. Must not be empty
    79  	// in server, might be empty in clients, might be queryable.
    80  	Actor() SessionSubjectT
    81  
    82  	// Session returns the session by the actor to delegate the action.
    83  	// Must not be empty in server, might be empty in clients.
    84  	Session() SessionT
    85  }