annotate pkg/imports/scheduled.go @ 2044:ea0b62b7656b unify_imports

Imports: Unified JSON marshaling of times and durations in imports.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 25 Jan 2019 17:54:02 +0100
parents 58b77f6b8764
children 78002c5e838c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1551
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 // This is Free Software under GNU Affero General Public License v >= 3.0
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2 // without warranty, see README.md and license for details.
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 //
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 // SPDX-License-Identifier: AGPL-3.0-or-later
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 // License-Filename: LICENSES/AGPL-3.0.txt
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 //
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 // Copyright (C) 2018 by via donau
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 // – Österreichische Wasserstraßen-Gesellschaft mbH
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 // Software engineering by Intevation GmbH
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 //
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 // Author(s):
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de>
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 package imports
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 import (
1748
c11807dc6940 Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1746
diff changeset
17 "context"
c11807dc6940 Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1746
diff changeset
18 "database/sql"
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
19 "fmt"
1551
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 "log"
2043
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
21 "time"
1551
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22
2043
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
23 "gemma.intevation.de/gemma/pkg/common"
2042
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
24 "gemma.intevation.de/gemma/pkg/models"
1551
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25 "gemma.intevation.de/gemma/pkg/scheduler"
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 )
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
28 func init() {
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
29 run := func(cfgID int64) {
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
30 jobID, err := RunConfiguredImport(cfgID)
1665
da0d1a19ebe6 Fairway availability import: Made schedulable, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1661
diff changeset
31 if err != nil {
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
32 log.Printf("error: running scheduled import failed: %v\n", err)
1705
dcbe2a7dc532 Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1678
diff changeset
33 return
dcbe2a7dc532 Scheduled imports: Take extra configuration parameters from attributes table.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1678
diff changeset
34 }
1665
da0d1a19ebe6 Fairway availability import: Made schedulable, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1661
diff changeset
35 log.Printf("info: added import #%d to queue\n", jobID)
1661
51a0ba4ede41 Scheduled imports: Made gauge measurement import able to be scheduled.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1654
diff changeset
36 }
51a0ba4ede41 Scheduled imports: Made gauge measurement import able to be scheduled.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1654
diff changeset
37
2042
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
38 for kind := range kindToImportModel {
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
39 scheduler.RegisterAction(string(kind), run)
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
40 }
1551
d9eba69f6515 Registered a dummy callback function for scheduled fairway imports in the scheduler.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 }
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
42
1748
c11807dc6940 Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1746
diff changeset
43 // RunConfiguredImportContext runs an import configured from the database.
c11807dc6940 Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1746
diff changeset
44 func RunConfiguredImportContext(ctx context.Context, conn *sql.Conn, id int64) (int64, error) {
2042
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
45 cfg, err := LoadPersistentConfigContext(ctx, conn, id)
1748
c11807dc6940 Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1746
diff changeset
46 return runConfiguredImport(id, cfg, err)
c11807dc6940 Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1746
diff changeset
47 }
c11807dc6940 Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1746
diff changeset
48
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
49 // RunConfiguredImport runs an import configured from the database.
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
50 func RunConfiguredImport(id int64) (int64, error) {
2042
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
51 cfg, err := loadPersistentConfig(id)
1748
c11807dc6940 Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1746
diff changeset
52 return runConfiguredImport(id, cfg, err)
c11807dc6940 Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1746
diff changeset
53 }
c11807dc6940 Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1746
diff changeset
54
2042
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
55 func runConfiguredImport(id int64, cfg *PersistentConfig, err error) (int64, error) {
1748
c11807dc6940 Comfigured imports: Run enqueing of configured imports if triggered by REST with the database connection of the logged in user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1746
diff changeset
56
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
57 if err != nil {
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
58 return 0, err
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
59 }
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
60 if cfg == nil {
2042
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
61 return 0, fmt.Errorf("no config found for id %d.", id)
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
62 }
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
63
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
64 kind := JobKind(cfg.Kind)
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
65
2042
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
66 ctor := ImportModelForJobKind(kind)
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
67 if ctor == nil {
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
68 return 0, fmt.Errorf("no constructor for kind '%s'.", cfg.Kind)
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
69 }
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
70
2042
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
71 what := ctor()
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
72
2043
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
73 // Fill the data structure
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
74 if um, ok := what.(common.AttributesUnmarshaler); ok {
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
75 if err := um.UnmarshalAttributes(cfg.Attributes); err != nil {
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
76 return 0, err
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
77 }
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
78 }
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
79
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
80 converted := ConvertToInternal(kind, what)
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
81 if converted == nil {
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
82 return 0, fmt.Errorf("Conversion of model for kind '%s' failed.", kind)
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
83 }
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
84
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
85 var serialized string
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
86 if serialized, err = common.ToJSONString(converted); err != nil {
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
87 return 0, err
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
88 }
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
89
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
90 // Extract the job runtime parameters.
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
91 var (
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
92 email bool
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
93 due time.Time
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
94 trys *int
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
95 waitRetry *time.Duration
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
96 )
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
97
2042
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
98 if gqc, ok := what.(models.QueueConfigurationGetter); ok {
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
99 qc := gqc.GetQueueConfiguration()
2043
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
100 if qc.Due != nil {
2044
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2043
diff changeset
101 due = qc.Due.Time
2043
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
102 }
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
103 trys = qc.Trys
2044
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2043
diff changeset
104 if qc.WaitRetry != nil {
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2043
diff changeset
105 waitRetry = &qc.WaitRetry.Duration
ea0b62b7656b Imports: Unified JSON marshaling of times and durations in imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2043
diff changeset
106 }
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
107 }
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
108
2042
d29ac997eb34 This breaks this branch!!!! Starting to remove the old persistent layer for configured imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1985
diff changeset
109 if ge, ok := what.(models.EmailTypeGetter); ok {
2043
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
110 email = ge.GetEmailType().Email
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
111 }
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
112
2043
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
113 var jobID int64
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
114 if jobID, err = AddJob(
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
115 kind,
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
116 due,
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
117 trys,
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
118 waitRetry,
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
119 cfg.User,
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
120 email,
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
121 serialized,
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
122 ); err != nil {
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
123 return 0, err
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
124 }
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
125
2043
58b77f6b8764 Imports: completed the starting of a scheduled job.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2042
diff changeset
126 return jobID, nil
1729
74f7d4c531bc Scheduled imports: Refactored calling of database configured import to be reusable elsewhere.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1708
diff changeset
127 }