github.com/voedger/voedger@v0.0.0-20240520144910-273e84102129/pkg/state/impl_command_processor_state.go (about)

     1  /*
     2   * Copyright (c) 2022-present unTill Pro, Ltd.
     3   */
     4  
     5  package state
     6  
     7  import (
     8  	"context"
     9  
    10  	"github.com/voedger/voedger/pkg/isecrets"
    11  	"github.com/voedger/voedger/pkg/istructs"
    12  )
    13  
    14  func implProvideCommandProcessorState(ctx context.Context, appStructsFunc AppStructsFunc, partitionIDFunc PartitionIDFunc,
    15  	wsidFunc WSIDFunc, secretReader isecrets.ISecretReader, cudFunc CUDFunc, principalsFunc PrincipalsFunc,
    16  	tokenFunc TokenFunc, intentsLimit int, cmdResultBuilderFunc ObjectBuilderFunc, argFunc ArgFunc, unloggedArgFunc UnloggedArgFunc,
    17  	wlogOffsetFunc WLogOffsetFunc) IHostState {
    18  	bs := newHostState("CommandProcessor", intentsLimit, appStructsFunc)
    19  
    20  	bs.addStorage(View, newViewRecordsStorage(ctx, appStructsFunc, wsidFunc, nil), S_GET|S_GET_BATCH)
    21  	bs.addStorage(Record, newRecordsStorage(appStructsFunc, wsidFunc, cudFunc), S_GET|S_GET_BATCH|S_INSERT|S_UPDATE)
    22  
    23  	bs.addStorage(WLog, &wLogStorage{
    24  		ctx:        ctx,
    25  		eventsFunc: func() istructs.IEvents { return appStructsFunc().Events() },
    26  		wsidFunc:   wsidFunc,
    27  	}, S_GET)
    28  
    29  	bs.addStorage(AppSecret, &appSecretsStorage{secretReader: secretReader}, S_GET)
    30  
    31  	bs.addStorage(RequestSubject, &subjectStorage{
    32  		principalsFunc: principalsFunc,
    33  		tokenFunc:      tokenFunc,
    34  	}, S_GET)
    35  
    36  	bs.addStorage(Result, newCmdResultStorage(cmdResultBuilderFunc), S_INSERT)
    37  
    38  	bs.addStorage(Response, &cmdResponseStorage{}, S_INSERT)
    39  
    40  	bs.addStorage(CommandContext, &commandContextStorage{
    41  		argFunc:         argFunc,
    42  		unloggedArgFunc: unloggedArgFunc,
    43  		wsidFunc:        wsidFunc,
    44  		wlogOffsetFunc:  wlogOffsetFunc,
    45  	}, S_GET)
    46  
    47  	return bs
    48  }