1
0
Fork 0
mirror of https://github.com/postmannen/ctrl.git synced 2025-03-31 01:24:31 +00:00

renamed HandlerFunc to Handler

This commit is contained in:
postmannen 2025-01-02 04:57:27 +01:00
parent 894bdf2554
commit 2f1f2ea28b

View file

@ -166,7 +166,7 @@ const (
AclImport = "aclImport"
)
type HandlerFunc func(proc process, message Message, node string) ([]byte, error)
type Handler func(proc process, message Message, node string) ([]byte, error)
// The mapping of all the method constants specified, what type
// it references.
@ -177,52 +177,52 @@ type HandlerFunc func(proc process, message Message, node string) ([]byte, error
func (m Method) GetMethodsAvailable() MethodsAvailable {
ma := MethodsAvailable{
Methodhandlers: map[Method]HandlerFunc{
Initial: HandlerFunc(methodInitial),
OpProcessList: HandlerFunc(methodOpProcessList),
OpProcessStart: HandlerFunc(methodOpProcessStart),
OpProcessStop: HandlerFunc(methodOpProcessStop),
CliCommand: HandlerFunc(methodCliCommand),
CliCommandCont: HandlerFunc(methodCliCommandCont),
Console: HandlerFunc(methodConsole),
FileAppend: HandlerFunc(methodFileAppend),
File: HandlerFunc(methodToFile),
CopySrc: HandlerFunc(methodCopySrc),
CopyDst: HandlerFunc(methodCopyDst),
SUBCopySrc: HandlerFunc(methodSUB),
SUBCopyDst: HandlerFunc(methodSUB),
Hello: HandlerFunc(methodHello),
Methodhandlers: map[Method]Handler{
Initial: Handler(methodInitial),
OpProcessList: Handler(methodOpProcessList),
OpProcessStart: Handler(methodOpProcessStart),
OpProcessStop: Handler(methodOpProcessStop),
CliCommand: Handler(methodCliCommand),
CliCommandCont: Handler(methodCliCommandCont),
Console: Handler(methodConsole),
FileAppend: Handler(methodFileAppend),
File: Handler(methodToFile),
CopySrc: Handler(methodCopySrc),
CopyDst: Handler(methodCopyDst),
SUBCopySrc: Handler(methodSUB),
SUBCopyDst: Handler(methodSUB),
Hello: Handler(methodHello),
// The hello publisher will not subscribe for messages, it will
// only start a procFunc, so we we don't need a handler with a method,
// so we set it to nil.
HelloPublisher: HandlerFunc(nil),
ErrorLog: HandlerFunc(methodErrorLog),
HttpGet: HandlerFunc(methodHttpGet),
HttpGetScheduled: HandlerFunc(methodHttpGetScheduled),
TailFile: HandlerFunc(methodTailFile),
PublicKey: HandlerFunc(methodPublicKey),
HelloPublisher: Handler(nil),
ErrorLog: Handler(methodErrorLog),
HttpGet: Handler(methodHttpGet),
HttpGetScheduled: Handler(methodHttpGetScheduled),
TailFile: Handler(methodTailFile),
PublicKey: Handler(methodPublicKey),
KeysRequestUpdatePublisher: HandlerFunc(methodKeysRequestUpdate),
KeysRequestUpdate: HandlerFunc(nil),
KeysDeliverUpdate: HandlerFunc(methodKeysReceiveUpdate),
KeysAllow: HandlerFunc(methodKeysAllow),
KeysDelete: HandlerFunc(methodKeysDelete),
KeysRequestUpdatePublisher: Handler(methodKeysRequestUpdate),
KeysRequestUpdate: Handler(nil),
KeysDeliverUpdate: Handler(methodKeysReceiveUpdate),
KeysAllow: Handler(methodKeysAllow),
KeysDelete: Handler(methodKeysDelete),
AclRequestUpdate: HandlerFunc(methodAclRequestUpdate),
AclDeliverUpdate: HandlerFunc(methodAclDeliverUpdate),
AclRequestUpdate: Handler(methodAclRequestUpdate),
AclDeliverUpdate: Handler(methodAclDeliverUpdate),
AclAddCommand: HandlerFunc(methodAclAddCommand),
AclDeleteCommand: HandlerFunc(methodAclDeleteCommand),
AclDeleteSource: HandlerFunc(methodAclDeleteSource),
AclGroupNodesAddNode: HandlerFunc(methodAclGroupNodesAddNode),
AclGroupNodesDeleteNode: HandlerFunc(methodAclGroupNodesDeleteNode),
AclGroupNodesDeleteGroup: HandlerFunc(methodAclGroupNodesDeleteGroup),
AclGroupCommandsAddCommand: HandlerFunc(methodAclGroupCommandsAddCommand),
AclGroupCommandsDeleteCommand: HandlerFunc(methodAclGroupCommandsDeleteCommand),
AclGroupCommandsDeleteGroup: HandlerFunc(methodAclGroupCommandsDeleteGroup),
AclExport: HandlerFunc(methodAclExport),
AclImport: HandlerFunc(methodAclImport),
Test: HandlerFunc(methodTest),
AclAddCommand: Handler(methodAclAddCommand),
AclDeleteCommand: Handler(methodAclDeleteCommand),
AclDeleteSource: Handler(methodAclDeleteSource),
AclGroupNodesAddNode: Handler(methodAclGroupNodesAddNode),
AclGroupNodesDeleteNode: Handler(methodAclGroupNodesDeleteNode),
AclGroupNodesDeleteGroup: Handler(methodAclGroupNodesDeleteGroup),
AclGroupCommandsAddCommand: Handler(methodAclGroupCommandsAddCommand),
AclGroupCommandsDeleteCommand: Handler(methodAclGroupCommandsDeleteCommand),
AclGroupCommandsDeleteGroup: Handler(methodAclGroupCommandsDeleteGroup),
AclExport: Handler(methodAclExport),
AclImport: Handler(methodAclImport),
Test: Handler(methodTest),
},
}
@ -232,7 +232,7 @@ func (m Method) GetMethodsAvailable() MethodsAvailable {
// getHandler will check the methodsAvailable map, and return the
// method handler for the method given
// as input argument.
func (m Method) getHandler(method Method) HandlerFunc {
func (m Method) getHandler(method Method) Handler {
ma := m.GetMethodsAvailable()
mh, _ := ma.CheckIfExists(method)
// mh := ma.Methodhandlers[method]
@ -280,13 +280,13 @@ func methodSUB(proc process, message Message, node string) ([]byte, error) {
// MethodsAvailable holds a map of all the different method types and the
// associated handler to that method type.
type MethodsAvailable struct {
Methodhandlers map[Method]HandlerFunc
Methodhandlers map[Method]Handler
}
// Check if exists will check if the Method is defined. If true the bool
// value will be set to true, and the methodHandler function for that type
// will be returned.
func (ma MethodsAvailable) CheckIfExists(m Method) (HandlerFunc, bool) {
func (ma MethodsAvailable) CheckIfExists(m Method) (Handler, bool) {
// First check if it is a sub process.
if strings.HasPrefix(string(m), "sub") {
// Strip of the uuid after the method name.