Skip to content

Commit 952f702

Browse files
authored
Code of conduct (#128)
- also fix `doc.go` - also make `conductor` struct private
1 parent d30f87c commit 952f702

File tree

4 files changed

+81
-33
lines changed

4 files changed

+81
-33
lines changed

CODE_OF_CONDUCT.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Code of Conduct
2+
3+
As contributors and maintainers of DBOS Transact, we pledge to respect everyone who contributes by posting issues, updating documentation, submitting pull requests, providing feedback in comments, and any other activities.
4+
5+
## Our Standards
6+
7+
Examples of behavior that contributes to creating a positive environment include:
8+
9+
- Using welcoming and inclusive language.
10+
- Being respectful of differing viewpoints and experiences.
11+
- Gracefully accepting constructive criticism.
12+
- Focusing on what is best for the community.
13+
- Showing empathy towards other community members.
14+
15+
Examples of unacceptable behavior by participants include:
16+
17+
- The use of sexualized language or imagery and unwelcome sexual attention or advances.
18+
- Trolling, insulting/derogatory comments, and personal or political attacks.
19+
- Public or private harassment.
20+
- Publishing others' private information, such as physical or electronic addresses, without explicit permission.
21+
- Other conduct which could reasonably be considered inappropriate in a professional setting
22+
Our Responsibilities.
23+
- Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
24+
25+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned with this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
26+
27+
## Scope
28+
29+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
30+
31+
## Enforcement
32+
33+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at
34+
[email protected]. All complaints will be reviewed and investigated promptly and fairly.
35+
36+
All project team members are obligated to respect the privacy and security of the reporter of any incident.
37+
38+
## Enforcement Guidelines
39+
40+
Project maintainers will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
41+
42+
- 1st offense: Verbal warning
43+
- 2nd offense: Written warning
44+
- 3rd offense: Temporary ban
45+
- 4th offense: Permanent ban
46+
47+
## Attribution
48+
49+
This Code of Conduct is adapted from the Contributor Covenant, version 2.0, available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

dbos/conductor.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ type conductorConfig struct {
3333
appName string
3434
}
3535

36-
// Conductor manages the WebSocket connection to the DBOS conductor service
37-
type Conductor struct {
36+
// conductor manages the WebSocket connection to the DBOS conductor service
37+
type conductor struct {
3838
dbosCtx *dbosContext
3939
logger *slog.Logger
4040

@@ -56,13 +56,13 @@ type Conductor struct {
5656
}
5757

5858
// launch starts the conductor main goroutine
59-
func (c *Conductor) launch() {
59+
func (c *conductor) launch() {
6060
c.logger.Info("Launching conductor")
6161
c.wg.Add(1)
6262
go c.run()
6363
}
6464

65-
func newConductor(dbosCtx *dbosContext, config conductorConfig) (*Conductor, error) {
65+
func newConductor(dbosCtx *dbosContext, config conductorConfig) (*conductor, error) {
6666
if config.apiKey == "" {
6767
return nil, fmt.Errorf("conductor API key is required")
6868
}
@@ -81,7 +81,7 @@ func newConductor(dbosCtx *dbosContext, config conductorConfig) (*Conductor, err
8181
Path: baseURL.JoinPath("websocket", config.appName, config.apiKey).Path,
8282
}
8383

84-
c := &Conductor{
84+
c := &conductor{
8585
dbosCtx: dbosCtx,
8686
url: wsURL,
8787
pingInterval: _PING_INTERVAL,
@@ -96,7 +96,7 @@ func newConductor(dbosCtx *dbosContext, config conductorConfig) (*Conductor, err
9696
return c, nil
9797
}
9898

99-
func (c *Conductor) shutdown(timeout time.Duration) {
99+
func (c *conductor) shutdown(timeout time.Duration) {
100100
c.stopOnce.Do(func() {
101101
if c.pingCancel != nil {
102102
c.pingCancel()
@@ -120,14 +120,14 @@ func (c *Conductor) shutdown(timeout time.Duration) {
120120
}
121121

122122
// reconnectWaitWithJitter adds random jitter to the reconnect wait time to prevent thundering herd
123-
func (c *Conductor) reconnectWaitWithJitter() time.Duration {
123+
func (c *conductor) reconnectWaitWithJitter() time.Duration {
124124
// Add jitter: random value between 0.5 * wait and 1.5 * wait
125125
jitter := 0.5 + rand.Float64() // #nosec G404 -- jitter for backoff doesn't need crypto-secure randomness
126126
return time.Duration(float64(c.reconnectWait) * jitter)
127127
}
128128

129129
// closeConn closes the connection and signals that reconnection is needed
130-
func (c *Conductor) closeConn() {
130+
func (c *conductor) closeConn() {
131131
// Cancel ping goroutine first
132132
if c.pingCancel != nil {
133133
c.pingCancel()
@@ -156,7 +156,7 @@ func (c *Conductor) closeConn() {
156156
c.needsReconnect.Store(true)
157157
}
158158

159-
func (c *Conductor) run() {
159+
func (c *conductor) run() {
160160
defer c.wg.Done()
161161

162162
for {
@@ -229,7 +229,7 @@ func (c *Conductor) run() {
229229
}
230230
}
231231

232-
func (c *Conductor) connect() error {
232+
func (c *conductor) connect() error {
233233
c.logger.Debug("Connecting to conductor")
234234

235235
dialer := websocket.Dialer{
@@ -290,7 +290,7 @@ func (c *Conductor) connect() error {
290290
return nil
291291
}
292292

293-
func (c *Conductor) ping() error {
293+
func (c *conductor) ping() error {
294294
c.writeMu.Lock()
295295
defer c.writeMu.Unlock()
296296

@@ -313,7 +313,7 @@ func (c *Conductor) ping() error {
313313
return nil
314314
}
315315

316-
func (c *Conductor) handleMessage(data []byte) error {
316+
func (c *conductor) handleMessage(data []byte) error {
317317
var base baseMessage
318318
if err := json.Unmarshal(data, &base); err != nil {
319319
c.logger.Error("Failed to parse message", "error", err)
@@ -350,7 +350,7 @@ func (c *Conductor) handleMessage(data []byte) error {
350350
}
351351
}
352352

353-
func (c *Conductor) handleExecutorInfoRequest(data []byte, requestID string) error {
353+
func (c *conductor) handleExecutorInfoRequest(data []byte, requestID string) error {
354354
var req executorInfoRequest
355355
if err := json.Unmarshal(data, &req); err != nil {
356356
c.logger.Error("Failed to parse executor info request", "error", err)
@@ -379,7 +379,7 @@ func (c *Conductor) handleExecutorInfoRequest(data []byte, requestID string) err
379379
return c.sendResponse(response, string(executorInfo))
380380
}
381381

382-
func (c *Conductor) handleRecoveryRequest(data []byte, requestID string) error {
382+
func (c *conductor) handleRecoveryRequest(data []byte, requestID string) error {
383383
var req recoveryConductorRequest
384384
if err := json.Unmarshal(data, &req); err != nil {
385385
c.logger.Error("Failed to parse recovery request", "error", err)
@@ -414,7 +414,7 @@ func (c *Conductor) handleRecoveryRequest(data []byte, requestID string) error {
414414
return c.sendResponse(response, string(recoveryMessage))
415415
}
416416

417-
func (c *Conductor) handleCancelWorkflowRequest(data []byte, requestID string) error {
417+
func (c *conductor) handleCancelWorkflowRequest(data []byte, requestID string) error {
418418
var req cancelWorkflowConductorRequest
419419
if err := json.Unmarshal(data, &req); err != nil {
420420
c.logger.Error("Failed to parse cancel workflow request", "error", err)
@@ -448,7 +448,7 @@ func (c *Conductor) handleCancelWorkflowRequest(data []byte, requestID string) e
448448
return c.sendResponse(response, string(cancelWorkflowMessage))
449449
}
450450

451-
func (c *Conductor) handleResumeWorkflowRequest(data []byte, requestID string) error {
451+
func (c *conductor) handleResumeWorkflowRequest(data []byte, requestID string) error {
452452
var req resumeWorkflowConductorRequest
453453
if err := json.Unmarshal(data, &req); err != nil {
454454
c.logger.Error("Failed to parse resume workflow request", "error", err)
@@ -483,7 +483,7 @@ func (c *Conductor) handleResumeWorkflowRequest(data []byte, requestID string) e
483483
return c.sendResponse(response, string(resumeWorkflowMessage))
484484
}
485485

486-
func (c *Conductor) handleRetentionRequest(data []byte, requestID string) error {
486+
func (c *conductor) handleRetentionRequest(data []byte, requestID string) error {
487487
var req retentionConductorRequest
488488
if err := json.Unmarshal(data, &req); err != nil {
489489
c.logger.Error("Failed to parse retention request", "error", err)
@@ -551,7 +551,7 @@ func (c *Conductor) handleRetentionRequest(data []byte, requestID string) error
551551
return c.sendResponse(response, string(retentionMessage))
552552
}
553553

554-
func (c *Conductor) handleListWorkflowsRequest(data []byte, requestID string) error {
554+
func (c *conductor) handleListWorkflowsRequest(data []byte, requestID string) error {
555555
var req listWorkflowsConductorRequest
556556
if err := json.Unmarshal(data, &req); err != nil {
557557
c.logger.Error("Failed to parse list workflows request", "error", err)
@@ -628,7 +628,7 @@ func (c *Conductor) handleListWorkflowsRequest(data []byte, requestID string) er
628628
return c.sendResponse(response, string(listWorkflowsMessage))
629629
}
630630

631-
func (c *Conductor) handleListQueuedWorkflowsRequest(data []byte, requestID string) error {
631+
func (c *conductor) handleListQueuedWorkflowsRequest(data []byte, requestID string) error {
632632
var req listWorkflowsConductorRequest
633633
if err := json.Unmarshal(data, &req); err != nil {
634634
c.logger.Error("Failed to parse list queued workflows request", "error", err)
@@ -715,7 +715,7 @@ func (c *Conductor) handleListQueuedWorkflowsRequest(data []byte, requestID stri
715715
return c.sendResponse(response, string(listQueuedWorkflowsMessage))
716716
}
717717

718-
func (c *Conductor) handleListStepsRequest(data []byte, requestID string) error {
718+
func (c *conductor) handleListStepsRequest(data []byte, requestID string) error {
719719
var req listStepsConductorRequest
720720
if err := json.Unmarshal(data, &req); err != nil {
721721
c.logger.Error("Failed to parse list steps request", "error", err)
@@ -764,7 +764,7 @@ func (c *Conductor) handleListStepsRequest(data []byte, requestID string) error
764764
return c.sendResponse(response, string(listStepsMessage))
765765
}
766766

767-
func (c *Conductor) handleGetWorkflowRequest(data []byte, requestID string) error {
767+
func (c *conductor) handleGetWorkflowRequest(data []byte, requestID string) error {
768768
var req getWorkflowConductorRequest
769769
if err := json.Unmarshal(data, &req); err != nil {
770770
c.logger.Error("Failed to parse get workflow request", "error", err)
@@ -808,7 +808,7 @@ func (c *Conductor) handleGetWorkflowRequest(data []byte, requestID string) erro
808808
return c.sendResponse(response, string(getWorkflowMessage))
809809
}
810810

811-
func (c *Conductor) handleForkWorkflowRequest(data []byte, requestID string) error {
811+
func (c *conductor) handleForkWorkflowRequest(data []byte, requestID string) error {
812812
var req forkWorkflowConductorRequest
813813
if err := json.Unmarshal(data, &req); err != nil {
814814
c.logger.Error("Failed to parse fork workflow request", "error", err)
@@ -865,7 +865,7 @@ func (c *Conductor) handleForkWorkflowRequest(data []byte, requestID string) err
865865
return c.sendResponse(response, string(forkWorkflowMessage))
866866
}
867867

868-
func (c *Conductor) handleExistPendingWorkflowsRequest(data []byte, requestID string) error {
868+
func (c *conductor) handleExistPendingWorkflowsRequest(data []byte, requestID string) error {
869869
var req existPendingWorkflowsConductorRequest
870870
if err := json.Unmarshal(data, &req); err != nil {
871871
c.logger.Error("Failed to parse exist pending workflows request", "error", err)
@@ -902,7 +902,7 @@ func (c *Conductor) handleExistPendingWorkflowsRequest(data []byte, requestID st
902902
return c.sendResponse(response, string(existPendingWorkflowsMessage))
903903
}
904904

905-
func (c *Conductor) handleUnknownMessageType(requestID string, msgType messageType, errorMsg string) error {
905+
func (c *conductor) handleUnknownMessageType(requestID string, msgType messageType, errorMsg string) error {
906906
if c.conn == nil {
907907
return fmt.Errorf("no connection")
908908
}
@@ -918,7 +918,7 @@ func (c *Conductor) handleUnknownMessageType(requestID string, msgType messageTy
918918
return c.sendResponse(response, "unknown message type response")
919919
}
920920

921-
func (c *Conductor) sendResponse(response any, responseType string) error {
921+
func (c *conductor) sendResponse(response any, responseType string) error {
922922
c.writeMu.Lock()
923923
defer c.writeMu.Unlock()
924924

dbos/dbos.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ type DBOSContext interface {
115115
GetStepID() (int, error) // Get the current step ID (only available within workflows)
116116

117117
// Workflow management
118-
RetrieveWorkflow(_ DBOSContext, workflowID string) (WorkflowHandle[any], error) // Get a handle to an existing workflow
119-
CancelWorkflow(_ DBOSContext, workflowID string) error // Cancel a workflow by setting its status to CANCELLED
120-
ResumeWorkflow(_ DBOSContext, workflowID string) (WorkflowHandle[any], error) // Resume a cancelled workflow
121-
ForkWorkflow(_ DBOSContext, input ForkWorkflowInput) (WorkflowHandle[any], error) // Fork a workflow from a specific step
122-
ListWorkflows(_ DBOSContext, opts ...ListWorkflowsOption) ([]WorkflowStatus, error) // List workflows based on filtering criteria
123-
GetWorkflowSteps(_ DBOSContext, workflowID string) ([]StepInfo, error) // Get the execution steps of a workflow
118+
RetrieveWorkflow(_ DBOSContext, workflowID string) (WorkflowHandle[any], error) // Get a handle to an existing workflow
119+
CancelWorkflow(_ DBOSContext, workflowID string) error // Cancel a workflow by setting its status to CANCELLED
120+
ResumeWorkflow(_ DBOSContext, workflowID string) (WorkflowHandle[any], error) // Resume a cancelled workflow
121+
ForkWorkflow(_ DBOSContext, input ForkWorkflowInput) (WorkflowHandle[any], error) // Fork a workflow from a specific step
122+
ListWorkflows(_ DBOSContext, opts ...ListWorkflowsOption) ([]WorkflowStatus, error) // List workflows based on filtering criteria
123+
GetWorkflowSteps(_ DBOSContext, workflowID string) ([]StepInfo, error) // Get the execution steps of a workflow
124124

125125
// Accessors
126126
GetApplicationVersion() string // Get the application version for this context
@@ -142,7 +142,7 @@ type dbosContext struct {
142142
queueRunner *queueRunner
143143

144144
// Conductor client
145-
conductor *Conductor
145+
conductor *conductor
146146

147147
// Application metadata
148148
applicationVersion string

dbos/doc.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,4 @@
114114
// }
115115
//
116116
// For detailed documentation and examples, see https://docs.dbos.dev/golang/programming-guide
117-
118117
package dbos

0 commit comments

Comments
 (0)