using System;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
namespace test3
{
class Program
{
static void Main()
{
//HelloWorldWithWriter_Example();
//HelloWorldWithDecorator1_Example();
//HelloWorldWithManyWriters_Example();
//HelloWorldWithAdapter_Example();
//BankOperationReaderApp_Example2();
String news = "new string";
var IrisEmployee = new Employee("James Peters", "IRIS Software");
Console.WriteLine(IrisEmployee.FName);
Console.WriteLine("\nPress any key...");
Console.ReadLine();
}
class Person
{
int age = 1;
public virtual int Age
{
get => age;
set{ if(value > 0 && value < 110) age = value; }
}
public string Name { get; set; }
public Person(string name)
{
Name = name;
}
public virtual void Print() => Console.WriteLine(Name);
}
class Employee : Person
{
public string FName { get; set; }
public override int Age
{
get => base.Age;
set { if (value > 17 && value < 110) base.Age = value; }
}
public string Company { get; set; }
public Employee(string fName, string company)
{
FName = fName;
Company = company;
base.Age = 18; // возраст для работников по умолчанию
}
}
}
}
"""async testing module"""
import asyncio
import datetime
async def put_message_on_s3(message_date_: datetime, n_exec: int):
"""async function"""
x = (12 - n_exec) / 2 + 0.1
await asyncio.sleep(float(x))
print(
"message_date {} and number of execution = {}".format(
message_date_.strftime("%B %-d, %Y"), str(n_exec)
)
)
return "execution number: " + str(n_exec)
loop = asyncio.get_event_loop()
tasks = []
groups = []
groups_tuple = tuple()
async def main_func():
"""main async func"""
ind = 0
interim_results = []
while True:
mydate = datetime.datetime.now()
task = asyncio.ensure_future(put_message_on_s3(mydate, ind))
tasks.append(task)
ind += 1
print("\nNEXT MESSAGE\n")
await asyncio.sleep(1)
if ind >= 10:
break
for a_task in tasks:
interim_result = await a_task
interim_results.append(interim_result)
# print(interim_result)
return interim_results
loop = asyncio.get_event_loop()
if loop.is_closed():
loop = asyncio.new_event_loop()
completion = loop.run_until_complete(main_func())
print("put_message_on_s3()= {}".format(completion))
loop.close()
"""async testing module"""
import asyncio
import datetime
async def put_message_on_s3(message_date_: datetime, n_exec: int):
"""async function"""
x = (12 - n_exec) / 2 + 0.1
await asyncio.sleep(float(x))
print(
"message_date {} and number of execution = {}".format(
message_date_.strftime("%B %-d, %Y"), str(n_exec)
)
)
return "execution number: " + str(n_exec)
loop = asyncio.get_event_loop()
tasks = []
groups = []
groups_tuple = tuple()
async def main_func():
"""main async func"""
ind = 0
interim_results = []
while True:
mydate = datetime.datetime.now()
task = asyncio.ensure_future(put_message_on_s3(mydate, ind))
tasks.append(task)
ind += 1
print("\nNEXT MESSAGE\n")
await asyncio.sleep(1)
if ind >= 10:
break
for a_task in tasks:
interim_result = await a_task
interim_results.append(interim_result)
# print(interim_result)
return interim_results
loop = asyncio.get_event_loop()
if loop.is_closed():
loop = asyncio.new_event_loop()
completion = loop.run_until_complete(main_func())
print("put_message_on_s3()= {}".format(completion))
loop.close()
"""async testing module"""
import asyncio
import datetime
async def put_message_on_s3(message_date_: datetime, n_exec: int):
"""async function"""
x = (12 - n_exec) / 2 + 0.1
await asyncio.sleep(float(x))
print(
"message_date {} and number of execution = {}".format(
message_date_.strftime("%B %-d, %Y"), str(n_exec)
)
)
return "execution number: " + str(n_exec)
loop = asyncio.get_event_loop()
tasks = []
groups = []
groups_tuple = tuple()
async def main_func():
"""main async func"""
ind = 0
interim_results = []
while True:
mydate = datetime.datetime.now()
task = asyncio.ensure_future(put_message_on_s3(mydate, ind))
tasks.append(task)
ind += 1
print("\nNEXT MESSAGE\n")
await asyncio.sleep(1)
if ind >= 10:
break
for a_task in tasks:
interim_result = await a_task
interim_results.append(interim_result)
# print(interim_result)
return interim_results
loop = asyncio.get_event_loop()
if loop.is_closed():
loop = asyncio.new_event_loop()
completion = loop.run_until_complete(main_func())
print("put_message_on_s3()= {}".format(completion))
loop.close()
мы ставили HA Proxy на хосте (например на 443) и уже с него выводили на разные контейнера по портам - на основе путей http запроса. Не так уж и сложно.