MCPcopy Index your code
hub / github.com/cloudreve/cloudreve / slaveTaskPropsFromContext

Function slaveTaskPropsFromContext

service/node/task.go:90–124  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

88}
89
90func slaveTaskPropsFromContext(ctx context.Context) (*types.SlaveTaskProps, error) {
91 nodeIdStr, ok := ctx.Value(cluster.SlaveNodeIDCtx{}).(string)
92 if !ok {
93 return nil, fmt.Errorf("failed to get node ID from context")
94 }
95
96 nodeId, err := strconv.Atoi(nodeIdStr)
97 if err != nil {
98 return nil, fmt.Errorf("failed to convert node ID to int: %w", err)
99 }
100
101 masterSiteUrl := cluster.MasterSiteUrlFromContext(ctx)
102 if masterSiteUrl == "" {
103 return nil, fmt.Errorf("failed to get master site URL from context")
104 }
105
106 masterSiteVersion, ok := ctx.Value(cluster.MasterSiteVersionCtx{}).(string)
107 if !ok {
108 return nil, fmt.Errorf("failed to get master site version from context")
109 }
110
111 masterSiteId, ok := ctx.Value(cluster.MasterSiteIDCtx{}).(string)
112 if !ok {
113 return nil, fmt.Errorf("failed to convert master site ID to int: %w", err)
114 }
115
116 props := &types.SlaveTaskProps{
117 NodeID: nodeId,
118 MasterSiteID: masterSiteId,
119 MasterSiteURl: masterSiteUrl,
120 MasterSiteVersion: masterSiteVersion,
121 }
122
123 return props, nil
124}
125
126type (
127 FolderCleanupParamCtx struct{}

Callers 1

CreateTaskInSlaveFunction · 0.85

Calls 2

MasterSiteUrlFromContextFunction · 0.92
ValueMethod · 0.45

Tested by

no test coverage detected