fix: README
This commit is contained in:
parent
502b8cefc1
commit
afa90e9839
1 changed files with 158 additions and 158 deletions
132
README.md
132
README.md
|
@ -26,52 +26,52 @@ zig build
|
||||||
<details>
|
<details>
|
||||||
<summary>Python</summary>
|
<summary>Python</summary>
|
||||||
|
|
||||||
```python
|
```python
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
||||||
@app.get("/")
|
@app.get("/")
|
||||||
def read_root():
|
def read_root():
|
||||||
return {"Hello": "World"}
|
return {"Hello": "World"}
|
||||||
|
|
||||||
|
|
||||||
@app.get("/items/{item_id}")
|
@app.get("/items/{item_id}")
|
||||||
def read_item(item_id: int, q: Union[str, None] = None):
|
def read_item(item_id: int, q: Union[str, None] = None):
|
||||||
return {"item_id": item_id, "q": q}
|
return {"item_id": item_id, "q": q}
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
```
|
```
|
||||||
File: test.py
|
File: test.py
|
||||||
Language: python
|
Language: python
|
||||||
|
|
||||||
var app = FastAPI();
|
var app = FastAPI();
|
||||||
func read_root() -> void;
|
func read_root() -> void;
|
||||||
func read_item() -> void;
|
func read_item() -> void;
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Zig</summary>
|
<summary>Zig</summary>
|
||||||
|
|
||||||
```zig
|
```zig
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
const root = @import("root.zig");
|
const root = @import("root.zig");
|
||||||
const E = root.E;
|
const E = root.E;
|
||||||
const P3 = root.P3;
|
const P3 = root.P3;
|
||||||
const Vec3 = root.Vec3;
|
const Vec3 = root.Vec3;
|
||||||
const Sphere = root.Sphere;
|
const Sphere = root.Sphere;
|
||||||
const Ray = root.Ray;
|
const Ray = root.Ray;
|
||||||
const Interval = root.Interval;
|
const Interval = root.Interval;
|
||||||
|
|
||||||
pub const Hittable = union(enum) {
|
pub const Hittable = union(enum) {
|
||||||
const Self = @This();
|
const Self = @This();
|
||||||
sphere: Sphere,
|
sphere: Sphere,
|
||||||
|
|
||||||
|
@ -99,47 +99,47 @@ zig build
|
||||||
inline else => |hittable| return hittable.collisionAt(interval, ray),
|
inline else => |hittable| return hittable.collisionAt(interval, ray),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
```
|
```
|
||||||
File: /Users/bogdanbuduroiu/development/bruvduroiu/raytracing.zig/src/hittable.zig
|
File: /Users/bogdanbuduroiu/development/bruvduroiu/raytracing.zig/src/hittable.zig
|
||||||
Language: zig
|
Language: zig
|
||||||
|
|
||||||
var t;
|
var t;
|
||||||
var p;
|
var p;
|
||||||
var normal;
|
var normal;
|
||||||
var face;
|
var face;
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Go</summary>
|
<summary>Go</summary>
|
||||||
|
|
||||||
```go
|
```go
|
||||||
package batch_sliding_window
|
package batch_sliding_window
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go.temporal.io/sdk/temporal"
|
"go.temporal.io/sdk/temporal"
|
||||||
"go.temporal.io/sdk/workflow"
|
"go.temporal.io/sdk/workflow"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProcessBatchWorkflowInput input of the ProcessBatchWorkflow.
|
// ProcessBatchWorkflowInput input of the ProcessBatchWorkflow.
|
||||||
// A single input structure is preferred to multiple workflow arguments to simplify backward compatible API changes.
|
// A single input structure is preferred to multiple workflow arguments to simplify backward compatible API changes.
|
||||||
type ProcessBatchWorkflowInput struct {
|
type ProcessBatchWorkflowInput struct {
|
||||||
PageSize int // Number of children started by a single sliding window workflow run
|
PageSize int // Number of children started by a single sliding window workflow run
|
||||||
SlidingWindowSize int // Maximum number of children to run in parallel.
|
SlidingWindowSize int // Maximum number of children to run in parallel.
|
||||||
Partitions int // How many sliding windows to run in parallel.
|
Partitions int // How many sliding windows to run in parallel.
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProcessBatchWorkflow sample Partitions the data set into continuous ranges.
|
// ProcessBatchWorkflow sample Partitions the data set into continuous ranges.
|
||||||
// A real application can choose any other way to divide the records into multiple collections.
|
// A real application can choose any other way to divide the records into multiple collections.
|
||||||
func ProcessBatchWorkflow(ctx workflow.Context, input ProcessBatchWorkflowInput) (processed int, err error) {
|
func ProcessBatchWorkflow(ctx workflow.Context, input ProcessBatchWorkflowInput) (processed int, err error) {
|
||||||
ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
|
ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
|
||||||
StartToCloseTimeout: 5 * time.Second,
|
StartToCloseTimeout: 5 * time.Second,
|
||||||
})
|
})
|
||||||
|
@ -196,9 +196,9 @@ zig build
|
||||||
result += r
|
result += r
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func divideIntoPartitions(number int, n int) []int {
|
func divideIntoPartitions(number int, n int) []int {
|
||||||
base := number / n
|
base := number / n
|
||||||
remainder := number % n
|
remainder := number % n
|
||||||
partitions := make([]int, n)
|
partitions := make([]int, n)
|
||||||
|
@ -212,22 +212,22 @@ zig build
|
||||||
}
|
}
|
||||||
|
|
||||||
return partitions
|
return partitions
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Result:
|
Result:
|
||||||
|
|
||||||
```
|
```
|
||||||
File: /Users/bogdanbuduroiu/development/temporalio/samples-go/batch-
|
File: /Users/bogdanbuduroiu/development/temporalio/samples-go/batch-
|
||||||
sliding-window/batch_workflow.go
|
sliding-window/batch_workflow.go
|
||||||
Language: go
|
Language: go
|
||||||
|
|
||||||
class ProcessBatchWorkflowInput {
|
class ProcessBatchWorkflowInput {
|
||||||
};
|
};
|
||||||
var PageSize;
|
var PageSize;
|
||||||
var SlidingWindowSize;
|
var SlidingWindowSize;
|
||||||
var Partitions;
|
var Partitions;
|
||||||
func ProcessBatchWorkflow() -> void;
|
func ProcessBatchWorkflow() -> void;
|
||||||
func divideIntoPartitions() -> void;
|
func divideIntoPartitions() -> void;
|
||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
Loading…
Add table
Reference in a new issue