|
I starting a core 2.2 web API prototype that will feed a WPF application (I can knock a WPF app out rather quickly) so I only need the API and database.
Starting with a SQL Server database which will migrate to Azure if it goes to presentation. I intend to create a web API that serves up JSON data directly from the data table using:
string sResult = JsonConvert.SerializeObject(dtData); This means there are no models required for the select but do I need a model for the insert/update?
I am using a custom DAL (EF will NOT be entertained) that requires parameters so identifying the fields in the json string will be a requirement.
Alternatively should I use a model structure instead of a json string?
Can I also host the web api on Azure.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Mycroft Holmes wrote: Alternatively should I use a model structure instead of a json string?
I would use a model class for consistency and validation purposes, if nothing else. How you hydrate that model really doesn't matter (as far as the utility of the model class goes, at any rate). Additionally, if you ever intend to serve the data in a RESTful format, it will make that transition a lot easier. You should be able to process that model mapping fairly easily in your DAL.
Mycroft Holmes wrote: Can I also host the web api on Azure.
Yep. In fact, you could skip the WebAPI app entirely if you use the Azure CosmosDB, but that's only useful if an object store will serve your needs.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
I was definitely leaning towards the model structure as that is what I am used to. The project needs a purely relational database so SQL Server is always going to be my go to DB.
How do you test and insert/update if you are using a model transport format, mock the model in the method?
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
modified 5-Mar-19 17:39pm.
|
|
|
|
|
I think it's more important to build a good database mock to evaluate C/U method output for testing purposes, but that point is debatable.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
I have this that I want to create an API for and would like to do so using micro services.
I have people that are part of teams. Each team has a backlog with workitems in it.
I was thinking of creating the following microservices
/Person
GET - Return a list of person
POST - Create a new person
/Person/{PersonId}
GET - Return the person represented by PersonId
PUT - Update person represented by PersonId
DELETE - Delete person represented by PersonId
/Team
GET - Return a list of teams
POST - Create a new team
/Team/{TeamId}
GET - Return team represented by TeamId
PUT - Update team represented by TeamId
DELETE - Delete team represented by TeamId
Would do the same for Backlog and WorkItem.
The question I can't decide is where should the code go that returns the people in a given team? I mean should I have something like /team/12/members with a GET method that return the people in that team? That would make sens, but then, it would mean that the Team service would need access to the Person database, which violate microservice pattern.
Same, where would the code go to add a workitem to a backlog? /backlog/4/workitem with a POST looks reasonable to me..
So what is the normal way to deal with 0 to many relationship in the microservice world?
Any help would be appreciated!
Thanks
|
|
|
|
|
This is the type of thing that I would be tempted to solve using GraphQL.
This space for rent
|
|
|
|
|
"Micro services" are relative; what was "macro" yesterday, is micro today due to increased bandwindth, larger back-ends, and / or better design patterns.
Any service is micro if it is "fast", and doesn't require round-tripping and / or maintain state; regardless of the environment.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
The plus with microservices is that you can express them much as you would in native code. If you need a data structure, implement a data structure.
/TeamMember/{TeamId}
Get
Post
Delete
And so on. Don't start breaking the standard just to take shortcuts.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
microservices.io wrote: How to maintain data consistency?
In order to ensure loose coupling, each service has its own database. Source[^]
(It has a bit more to say on the subject than the one sentence I quoted, so I'd suggest reading it)
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Basically, I agree with Eddy Vlungen. What I would like to add is that in your example your microservices are too granular. Naturally you should split your microservices by business capabilities, not by entities.
|
|
|
|
|
In all the docs, it's said that Node makes use of non-blocking I/O.
I guess this is not something totally new. All high-performance servers have been using the same. Even on OS level or network level.
What's making Node.js claim this "non-blocking" tag so much?
I was thinking Apache/IIS or any servers meant for high-volume connections, should be using non-blocking I/O. (i.e I/O port completion model for IIS on Windows).
I still believe IIS should be using IOCP internally, but may be only to a limited extent? as the documents say traditional Servers (Apache/IIS) does create 1-to-1 thread for each client.
It's a bit puzzling, why Microsoft did not think about a Node like pure-Single-threaded solution for servers.
Summary of questions:
1. IIS is really a dumb, 1-to-1 thread spawning server for every connected client?
2. Why Microsoft couldnt think of a Node model for web server, when I/O port completion has been so widely used in so many enterprise level network, I/O frameworks?
Full Reset
modified 17-Dec-18 7:38am.
|
|
|
|
|
On the OS level it is not "non blocking IO", but simply threads and fibers.
Eytukan wrote: 1. IIS is really a dumb, 1-to-1 thread spawning server for every connected client? Yes and no. If it is serving a picture, it doesn't need 40 threads for that. IIS also serves applications, which may launch their own threads.
Eytukan wrote: 2. Why Microsoft couldnt think of a Node model for web server, when I/O port completion has been so widely used in so many enterprise level network, I/O frameworks? Node is limited to what JavaScript can do.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: On the OS level it is not "non blocking IO", but simply threads and fibers.
I meant OS objects, i.e Pipes, File, Sockets or anything that's compatible to work with IOCP.
Eddy Vluggen wrote: Node is limited to what JavaScript can do.
Yeah just saying about the architecture it's providing for scalable solutions.
Eddy Vluggen wrote: Yes and no. If it is serving a picture, it doesn't need 40 threads for that. IIS also serves applications, which may launch their own threads.
thanks
But Microsoft is now, happily embracing Node. I was just thinking why they couldnt think of doing this by themselves. And I was believing IIS puts IOCP to max use and an invention called "Node.js" would never be a surprise.
Full Reset
|
|
|
|
|
Eytukan wrote: I meant OS objects, i.e Pipes, File, Sockets or anything that's compatible to work with IOCP. JS isn't allowed to touch most OS objects, as it poses a security-risk.
Eytukan wrote: But Microsoft is now, happily embracing Node. I was just thinking why they couldnt think of doing this by themselves. They made that error before; they did their own version of Java, and it drowned.
I prefer to see them support existing stuff, over inventing an incompatible wheel again.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: They made that error before; they did their own version of Java, and it drowned.
Yep, that's the best thing they can do. I was just thinking, why they couldnt think of it first, may something called "IIS-lite", as they had the technology already.
But anyway, bummer! they are just followers now.
Full Reset
|
|
|
|
|
There already was an IIS lite; there was both IIS Express and PWS.
Eytukan wrote: But anyway, bummer! they are just followers now. With most of the world running Windows, that sounds far-fetched at least.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: There already was an IIS lite; there was both IIS Express and PWS.
If IIS was a rhino, IIS express & PWS were baby-rhinos. I was just wishing for a cheeta or a baby cheeta.
Eddy Vluggen wrote: With most of the world running Windows, that sounds far-fetched at least.
Where Microsoft leads today, exactly? OS/Office? this is primarily because of the 80's , 90's market-share establishment.
Anyway, there's still some bits of 'ms-fan-boy' left in me. That's why I'm wishing they do some "breakthrough" technology. Keeping aside OS & office tools, of course, Microsoft is following the industry lead by Google ,Amazon & co.
The only thing that reminds me of something totally good & breakthrough from MS , might be the introduction of MVVM pattern to the world. That the whole industry is following in one or other ways.
And possibly, Visual Studio Code IDE - it definitely made a punch into open-stack world.
These are all just good!. But a total industry leading tech, MS can easily do, if they innovate better.
Having thorough expertise over non-blocking I/O, IOCP, MS should have done it first, Before someone else could do a thing called "Node.js".
Cheers!
Full Reset
modified 19-Dec-18 3:41am.
|
|
|
|
|
Eytukan wrote: If IIS was a rhino, IIS express & PWS were baby-rhinos. I was just wishing for a cheeta or a baby cheeta. Don't underestimate both power and speed of a rhino. IIS is not a simple webserver, but a rather optimized one, with lots of options.
Eytukan wrote: Keeping aside OS & office tools, of course, Microsoft is following the industry lead by Google ,Amazon & co. Technical "lead" is not determined by stock-value. Most of us use .NET, not "Go".
Eytukan wrote: Having thorough expertise over non-blocking I/O, IOCP, MS should have done it first, Before someone else could do a thing called "Node.js" Executing JavaScript on a server? While we have .NET there? I can easily open a port and serve whatever I want, without the need for anything like interpreted JavaScript.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
First. Thank you for your replies with great manners.
And second, you can easily guess, I'm novice to "Node" or even IIS. But I could fairly figure out how things work. & More with your replies.
Eddy Vluggen wrote: Executing JavaScript on a server? While we have .NET there? I can easily open a port and serve whatever I want, without the need for anything like interpreted JavaScript.
True, but I still see various other things with Node & it's eco-system, and what it has opened up. Will write back once I get some time. I'll be happy if we can achieve the same with .net.
Please note, I'm not arguing on this topic. I'm just trying to discuss and figure out things. I don't know if i'm sounding so anit-Microsoft, in the process. I'm not.
Cheers!
Full Reset
|
|
|
|
|
Eytukan wrote: First. Thank you for your replies with great manners. Must have gone something wrong here, I'm the rude one usually.
Eytukan wrote: And second, you can easily guess, I'm novice to "Node" or even IIS. Write your own "tiny" webserver; all you need is to open a listening socket, and send some files
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Eddy Vluggen wrote: Must have gone something wrong here, I'm the rude one usually.
Eddy Vluggen wrote: Write your own "tiny" webserver; all you need is to open a listening socket, and send some files
Full Reset
|
|
|
|
|
|
He uses the canonical example of launching a webserver in node, and compares that to:
Want to do the same thing in .NET? Be prepared to learn about IIS, the Machine.config, the Web.config, the Process Model, how Global.asax works, either ASP.NET MVC or WebForms (huge paradigms in themselves), and how Visual Studio works That's rather unfair, and you can do without most of it.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Yup, "kestrel" might be a right fit for the comparison. Just looking at this after Pete pointed out a while ago.
Alright, Now I got the next pile of things to break-head & learn. Kestrel, OWIN, Katana, whatnotana
PS: I was thinking OWIN to be yet another services like OAuth., until I read the article I just posted above loll
Full Reset
|
|
|
|
|
|