It's time to let your babies grow up to be cowboys. 🎶
This commit is contained in:
parent
c5929e8cb1
commit
41f5bc5d67
@ -18,6 +18,7 @@ public class CanvasService {
|
||||
private IRedisService _redisService;
|
||||
private CanvasCommand _lastCommand = new();
|
||||
private List<CanvasCommand> _lsComms = new();
|
||||
private Guid _id = Guid.NewGuid();
|
||||
private bool _is_init = false,
|
||||
_is_started = false,
|
||||
_has_ended = false;
|
||||
@ -54,11 +55,12 @@ public class CanvasService {
|
||||
while (!_has_ended) {
|
||||
if (_lsComms.Count > 0)
|
||||
_lsComms.Clear();
|
||||
_lsComms.AddRange(await _redisService.Consume());
|
||||
_lsComms.AddRange(await _redisService.Consume(_id.ToString()));
|
||||
if (_lsComms.Count == 1)
|
||||
Draw(_lsComms[0]);
|
||||
else if (_lsComms.Count > 0)
|
||||
Draw(_lsComms);
|
||||
Task.Delay(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,5 +8,5 @@ public interface IRedisService {
|
||||
void Publish(CanvasCommand command);
|
||||
|
||||
void Produce(CanvasCommand command);
|
||||
Task<IEnumerable<CanvasCommand>> Consume();
|
||||
Task<IEnumerable<CanvasCommand>> Consume(string id);
|
||||
}
|
||||
|
@ -56,20 +56,22 @@ public class RedisService : IRedisService {
|
||||
|
||||
public async void Produce(CanvasCommand command) {
|
||||
arNve[0] = new NameValueEntry("command", JsonConvert.SerializeObject(command));
|
||||
await _database.StreamAddAsync(STREAM_NAME, arNve);
|
||||
_database.StreamAddAsync(STREAM_NAME, arNve);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<CanvasCommand>> Consume() {
|
||||
public async Task<IEnumerable<CanvasCommand>> Consume(string id) {
|
||||
List<CanvasCommand> lsComm = new();
|
||||
CanvasCommand? comm;
|
||||
var result = await _database.StreamReadGroupAsync(STREAM_NAME, GROUP_NAME, "commCon", ">");
|
||||
|
||||
var result = await _database.StreamReadGroupAsync(STREAM_NAME, GROUP_NAME, id, ">", 100);
|
||||
string json = "";
|
||||
foreach (var c in result) {
|
||||
await _database.StreamAcknowledgeAsync(STREAM_NAME, GROUP_NAME, c.Id);
|
||||
_database.StreamAcknowledgeAsync(STREAM_NAME, GROUP_NAME, c.Id);
|
||||
try {
|
||||
string json = c.Values.FirstOrDefault(x => x.Name == "command").Value.ToString();
|
||||
json = c.Values.FirstOrDefault(x => x.Name == "command").Value.ToString();
|
||||
comm = JsonConvert.DeserializeObject<CanvasCommand>(json);
|
||||
} catch { continue; }
|
||||
} catch {
|
||||
Console.WriteLine($"OH NO {json}");
|
||||
continue; }
|
||||
if (comm is not null)
|
||||
lsComm.Add(comm);
|
||||
}
|
||||
|
125
BlazorCanvas/BlazorCanvas.Server/Docker_Deploy.yaml
Normal file
125
BlazorCanvas/BlazorCanvas.Server/Docker_Deploy.yaml
Normal file
@ -0,0 +1,125 @@
|
||||
# First, add the API
|
||||
apiVersion: apps/v1
|
||||
# This will be the deployment setup
|
||||
kind: Deployment
|
||||
metadata:
|
||||
# Name your Deployment here
|
||||
name: blazorcanvas
|
||||
labels:
|
||||
# label your deployment
|
||||
app: BlazorCanvas-etc
|
||||
spec:
|
||||
# The number of pods/replicas to run
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
# selector to match the pod
|
||||
app: BlazorCanvas-etc
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
# label your pod
|
||||
app: BlazorCanvas-etc
|
||||
spec:
|
||||
containers:
|
||||
# Add the container name for Kubernetes
|
||||
- name: blazorcanvas
|
||||
# Add the local image name
|
||||
image: blazorcanvasserver:latest
|
||||
# never pull the image policy
|
||||
imagePullPolicy: Never
|
||||
ports:
|
||||
# port for running the container, le port sur lequel l'application du conteneur roule
|
||||
- containerPort: 8080
|
||||
- containerPort: 8081
|
||||
# First, add the API
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
# This will be the deployment setup
|
||||
kind: Deployment
|
||||
metadata:
|
||||
# Name your Deployment here
|
||||
name: francis-redis
|
||||
labels:
|
||||
# label your deployment
|
||||
app: redis-app
|
||||
spec:
|
||||
# The number of pods/replicas to run
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
# selector to match the pod
|
||||
app: redis-app
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
# label your pod
|
||||
app: redis-app
|
||||
spec:
|
||||
containers:
|
||||
# Add the container name for Kubernetes
|
||||
# Cette image est téléchargée en partant BlazorCanvas.AppHost et doit passer par minikube image load.
|
||||
- name: redis
|
||||
# Add the local image name
|
||||
image: redis:latest
|
||||
# never pull the image policy
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
# ports for running the container, le port sur lequel l'application du conteneur roule
|
||||
- containerPort: 6379
|
||||
env:
|
||||
- name: "REDIS_ARGS"
|
||||
value: "--appendonly yes --appendfsync everysec"
|
||||
---
|
||||
# First, add the Service API
|
||||
apiVersion: v1
|
||||
# This will be the Service setup
|
||||
kind: Service
|
||||
metadata:
|
||||
# Your service name
|
||||
name: francis-redis
|
||||
spec:
|
||||
selector:
|
||||
# selector that matches the pod
|
||||
app: redis-app
|
||||
# type of service
|
||||
type: LoadBalancer
|
||||
ports:
|
||||
- protocol: TCP
|
||||
# port for exposing the service
|
||||
port: 6379
|
||||
# portfor exposing the pod
|
||||
targetPort: 6379
|
||||
# port for exposing the node
|
||||
nodePort: 31121
|
||||
---
|
||||
# First, add the Service API
|
||||
apiVersion: v1
|
||||
# This will be the Service setup
|
||||
kind: Service
|
||||
metadata:
|
||||
# Your service name
|
||||
name: blazorcanvas-srv
|
||||
spec:
|
||||
selector:
|
||||
# selector that matches the pod
|
||||
app: BlazorCanvas-etc
|
||||
# type of service
|
||||
type: LoadBalancer
|
||||
ports:
|
||||
- protocol: TCP
|
||||
name: "http"
|
||||
# port for exposing the service
|
||||
port: 8080
|
||||
# portfor exposing the pod
|
||||
targetPort: 8080
|
||||
# port for exposing the node
|
||||
nodePort: 31122
|
||||
- protocol: TCP
|
||||
name: "https"
|
||||
# port for exposing the service
|
||||
port: 8081
|
||||
# portfor exposing the pod
|
||||
targetPort: 8081
|
||||
# port for exposing the node
|
||||
nodePort: 31123
|
@ -7,6 +7,6 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"cache": "host.docker.internal"
|
||||
"cache": "francis-redis"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user