Channel Service Update | 220707


220707

Channel Service update

-0703- I Got the Get to were I want it to be about now. I just finished the PUT It works, but took some messing about with. I spread the GET to different functions inside the handler for the separate Parm options. I really just need to read the docs for the REST standard cause technically its own service, but data structure wise it connected to the server. I mean at this level I one could argue that I should have just left them together, but I plan on making the channel more complex and that one could argue it should be its own service. I really don’t know I go back on forth every time I look at it. I assume its semantics, but I am probably wrong when I did this professionally I did not have think about just copy what the architect put. I mean I asked a few of them which came down that’s just how we do it. I also think about how long this taking me which is just sad, but then I don’t already have a huge code base to just look at see what’s right or anyone to tell me what they want cause it just me. Its Odd feeling one of some joy and aimlessness. Whatever that was odd tangent

2036 Okay I have lookup the name conventions Resource Naming - Restful API

Divide the resource archetypes into four categories (document, collection, store, and controller).

Document A document resource is a singular concept that is akin to an object instance or database record. Use “singular” name to denote document resource archetype.

http://api.example.com/device-management/managed-devices/{device-id}
http://api.example.com/user-management/users/{id}
http://api.example.com/user-management/users/admin

Collection Use the “plural” name to denote the collection resource archetype. A collection resource is a server-managed directory of resources.

http://api.example.com/device-management/managed-devices
http://api.example.com/user-management/users
http://api.example.com/user-management/users/{id}/accounts

Store A store is a client-managed resource repository. A store resource lets an API client put resources in, get them back out, and decide when to delete them. A store never generates new URIs. Instead, each stored resource has a URI. The URI was chosen by a client when the resource initially put it into the store. Use “plural” name to denote store resource archetype.

http://api.example.com/song-management/users/{id}/playlists

Controller A controller resource models a procedural concept. Controller resources are like executable functions, with parameters and return values, inputs, and outputs. Use “verb” to denote controller archetype

http://api.example.com/cart-management/users/{id}/cart/checkout
http://api.example.com/song-management/users/{id}/playlist/play 

** Apparently Consistency is Key **

The forward-slash (/) character is used in the path portion of the URI to indicate a hierarchical relationship between resources.

Hyphens can used to improve readability - this is one I really did not know about

Never use CRUD function names in the URI

Use query component to filter URI collection Often, you will encounter requirements where you will need a collection of resources sorted, filtered, or limited based on some specific resource attribute. For this requirement, do not create new APIs – instead, enable sorting, filtering, and pagination capabilities in resource collection API and pass the input parameters as query parameters. e.g.

http://api.example.com/device-management/managed-devices
http://api.example.com/device-management/managed-devices?region=USA
http://api.example.com/device-management/managed-devices?region=USA&brand=XYZ
http://api.example.com/device-management/managed-devices?region=USA&brand=XYZ&sort=installation-date

Okay that makes sense and this site what I was looking for I remembering learning most of this after reading, which mean I really did not know it kek.

_ 220708_0044 Okay got the basic functionally CRUD operations for the channel service complete. Will have to come back for better Error handling, error messages, robustness, code Consistency, Cleaner code. but from basic test happy path seems to work.

220708_0608 Alright I am looking at the Kafka integration again.

found this. Performance Test between confluent-kafka-go vs sarama-cluster

Granted I have no plan on using the confluent anything, but I did overlook sarama. Sarama was mention in the Kafka-go documentation.